Go to the first, previous, next, last section, table of contents.


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, and binds the variable tiger to the value fierce. In this case, both values are symbols preceded by a quote. The values could just as well have been another list or a string. The body of the let follows after the list holding the variables. In this case, 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 case, 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'.


Go to the first, previous, next, last section, table of contents.