3 Functions and Data

Interaction 3-1. Examples of calling Lisp functions.

cm> (* 2 pi)
6.283185307179586
cm> (define 2pi (* 2 pi))

cm> (list 2pi 2pi)
(6.283185307179586 6.283185307179586)
cm>

Example 3-1. Samples of integer notation.

44100
-1
10200301230302302440232313329382381
60
#xFFFF
#b-11110000

Example 3-2. Samples of real number notation.

440.0
4.3E+2
-.25
33.33333333333333
6.5E-10

Example 3-3. Samples of ratio notation.

13/21
5/3
-3/4

Example 3-4. Samples of symbol notation.

c-sharp-minor
+
*tempo*
sfz
:sounds-good

Example 3-5. Samples of list notation.

()
(0 3 7 11 2 5 9 1 4 6 8 10)
(how many violists does it
     take to screw in a light bulb?)
(3-7 (0 2 5) (0 1 1 0 1 0))
(staff violin-1
       (clef treble) 
       (signature c-minor)
       (meter 2 4)
       (measure (rest 8th) 
                (note g4 8th ff) 
                (note g4 8th) 
                (note g4 8th))
       (measure (note e4 half fermata)))

Example 3-6. Property list notation.

(duration 7/8 frequency 440
              amplitude ff timbre breathy)

Example 3-7. Keyword names in property lists.

(:duration 7/8 :frequency 440
           :amplitude ff :timbre breathy)

Example 3-8. Function call notation.

(* 2 pi)
(list 2 pi)
(* 440 (expt 2 1/12))

Example 3-9. Samples of boolean notation.

#f
#t