Class 7
- Fixed points and recursion
- Fixed point algorithms are naturally expressed recursively.
- Generic versus special case
- Its only a little harder (and in some ways easier) to write a function
that solves a generic fixed point problem rather than worrying about the
details of solving a specific fixed-point problem (like Newton's method).
- Functions that build functions
- In Lisp, it is no harder to return a function than it is to return a
list or other value. The abilities to pass functions as arguments and return functions
as results together simplify the task of building generic tools in Lisp,
like our fixed-point program or implementations of Newton's method.
Tools for the Day
Unfortunately, you cannot just "cut and paste" graphics produced in a program like
Mathematica or S into another application. Instead, you will typically
need to save them as a Postscript file. Today, we will see how to save Mathematica
plots as Postscript files that become part of a Latex document.
- Saving Mathematica plots
- The notebook
postscript.nb defines a function to make this chore pretty easy.
- Showing plots in Latex
- We will use the psfig options to import graphics into Latex documents,
viewing the results with ghostview. The small Tex file
myPlot.tex gives a very basic illustration of the
use of the psfig extensions.
Status of Projects
- Your page with a filling bibliography needs to be available.
Be sure to e-mail me the URL (http://...) for your pages today if you have
not done so already.
- My page is at steady small state.
Recursion and Searching, with local variables and functions
- Iterative programs
-
For many reasons, many of us tend to think of programs consisting
of lots and lots of possibly nested "do loops". Though I am trying
to make recursion seem natural (as well as computationally efficient
through the use of compilation and tail recursion),
Lisp also supports this more traditional style of programming.
- Macros
-
Some of Lisp's iteration constructs (like the "do" form) seem pretty
unnatural without a lot of practice and are often more general than
what is needed. Macros allow you to make your own "language" for iteration.
We will use a simple one that provides a "while loop".
- Comparisons
-
Often, the built-in functions are the last word in a problem. Use them
when they are available --- unless you have to construct special things
(like lists of values) that are not needed than for using the built-in
functions. Even though the built-in functions are fast, the overhead of
list construction can make this approach inferior to iterative or recursive
programs.
- Lisp script for today's class.
- class7.lsp
Next time
We take a special look at the simulation capabilities of Lisp-Stat and use them
to explore some of the basic properties and capabilities of Gibbs sampling.