next up previous
Contents Next: list (FUNCTION) Up: Appendix: Selected LISP Previous: length (FUNCTION)


Format: (let ((<var1> <init1>) (<var2> <init2>) . . (<varN> <initN>)) <body>)

Required arguments: 1

((<var> <init>)...): a list of zero or more lists having the form (<var>) or (<var> <init>). <var> must be a symbol appropriate as the name of a variable. <init> may be any LISP expression.

Optional arguments: arbitrary

<body>: any sequence of zero or more LISP expressions.

The <var>'s are established as local variables for the expressions in <body>. If a <var> is not accompanied by an <init> expression, it is initially bound to NIL. Otherwise, <init> is evaluated and assigned as the value of <var>. let evaluates all the expressions in <body> and returns the value of the last, or NIL if there are none.


>(let ((a)
   (and (not a) (not b)))

>(let ((a 3)
       (b 4))
   (setf a (+ a b))
   (setf b (+ a b))
   (+ a b))

© Colin Allen & Maneesh Dhagat
November 1999