ACL: < cl > or < COMMON-MUSIC >
GCL: > or COMMON-MUSIC>
MCL: ?
78
-31
(- 78 31)
(/ (+ 33 12) (- 21 10))
(* (- 23 (+ 4 58)) (/ 36 2) 7.0)
__________T__________
/ \
List _______Atom________
/ \
Symbol ________Number________
/ | \
___Rational___ Float Complex
/ \
Integer Ratio
function
\
(+ 35 48 96 32 1 15 3.0 -65)
\_____arguments________/
(/ (+ 2 3)(- 7 2))
\_____/\_____/
(/ 5 5 )
\________________/
1
sampling-rate
output-file
new-symbol
pi
(defvar A-4 440)
Note that defvar evaluates to its first argument. Now, if we evaluate our new variable:
A-4
(defvar A-5 (* A-4 2))
(defvar F-maj (F-4 A-4 C-5))
This produces an error because the interpreter is trying to evaluate the list (F-4 A-4 C-5) as a function call, interpreting the symbol F-4 as a function and the rest as its arguments. We have to tell the interpreter to not evaluate this list and to assign it as the value for the symbol F-maj.
(defvar F-maj (quote (F-4 A-4 C-5)))
(defvar F-maj '(F-4 A-4 C-5))
(defvar F-maj '(F-3 A-3 C-4))
F-maj
(setf F-maj '(F-3 A-3 C-4))
Note that setf evaluates to its second argument. Now the symbol F-maj is bound to its new value:
F-maj
(setf F-3 174.61 A-3 (/ A-4 2) C-4 261.62 A-1 (/ A-3 2))
Note that you can use setf to create new variables too.
Portions of this page come from Todd Feldman's handouts for CS 193L.
©1996-98 by Juan Pampin, juan@ccrma.stanford.edu