Sample let Expression
The following expression creates and gives initial values to the two variables zebra and tiger. The body of the let expression is a list which calls the message function.
(let ((zebra "stripes")
(tiger "fierce"))
(message "One kind of animal has %s and another is %s."
zebra tiger))Here, the varlist is ((zebra "stripes") (tiger "fierce")).
The two variables are zebra and tiger. Each variable is the first element of a two-element list and each value is the second element of its two-element list. In the varlist, Emacs binds the variable zebra to the value "stripes"[1], and binds the variable tiger to the value "fierce". In this example, both values are strings. The values could just as well have been another list or a symbol. The body of the let follows after the list holding the variables. In this example, the body is a list that uses the message function to print a string in the echo area.
You may evaluate the example in the usual fashion, by placing the cursor after the last parenthesis and typing C-x C-e. When you do this, the following will appear in the echo area:
"One kind of animal has stripes and another is fierce."As we have seen before, the message function prints its first argument, except for ‘%s’. In this example, the value of the variable zebra is printed at the location of the first ‘%s’ and the value of the variable tiger is printed at the location of the second ‘%s’.
According to Jared Diamond in Guns, Germs, and Steel, “… zebras become impossibly dangerous as they grow older” but the claim here is that they do not become fierce like a tiger. (1997, W. W. Norton and Co., ISBN 0-393-03894-2, page 171) ↩︎