5 Lisp Evaluation

Interaction 5-1. Some self-evaluating expressions.

cm> 44100
44100
cm> #xFFFF
65535
cm> .500
0.5
cm> "Ondes Martenot"
"Ondes Martenot"
cm>

Interaction 5-2. Symbols are evaluated as variables.

cm> pi
3.141592653589793
cm> messiaen
> Error: Unbound variable: messiaen Aborted
cm>

Interaction 5-3. Function call notation.

cm> (* 2 pi)
6.283185307179586
cm> (list 2 pi)
(2 3.141592653589793)
cm> (sin (* 2 pi 1/4))
1.0
cm>

Interaction 5-4. The effect of quote on evaluated expressions.

cm> '44100
44100
cm> '"Ondes Martenot"
"Ondes Martenot"
cm> pi
3.141592653589793
cm> 'pi
pi
cm> ''pi
'pi
cm> '(0 2 5)
(0 2 5)
cm> (* 2 pi)
6.283185307179586
cm> '(* 2 pi)
(* 2 pi)
cm>

Interaction 5-5. The effects of quote and backquote on lists.

cm> '(a b pi c)
(a b pi c)
cm> `(a b ,pi c)
(a b 3.141592653589793 c)
cm>

Interaction 5-6. Equivalent expressions using list and backquote

cm> (list 'a 'b pi 'c)
(a b 3.141592653589793 c)
cm> `(a b ,pi c)
(a b 3.141592653589793 c)
cm>

Chapter Source Code

The source code to all of the examples and interactions in this chapter can be found in the file eval.cm located in the same directory as the HTML file for this chapter. The source file can be edited in a text editor or evaluated inside the Common Music application.