Let
The let construct in Clojure allows local variables to be defined and initialized.
(let [ var1 init1 ... ] code )
(let [ d (* 2.0 r) c (* Math/PI d) ] ... )
Each variable is initialized with the value of the corresponding initialization code; these initialization steps are executed in order, so the result of one can be used in later init code.[This is called let* is some Lisp dialects.]
let is useful to save the result of a (possibly expensive) function call so that it can be used multiple times without having to be recomputed.
There can be multiple forms inside the let; the value of the let is the value of the last form.
(defn lookupstudent [eid] (let [idname (assocl eid alist)] (if idname (second idname) "John Doe") ) )