Ch2 Programming
Associations and Properties
An “association list” has the form ((key1 value1) (key2 value2))
. The assoc
function takes in a key and returns the
(key value)
list .
(defparameter *info* '((good 50) (bad -10)))
(defun get-good ()
(assoc 'good *info*))
; (get-good) => '(good 50)
For completeness, a “property list” has the form (:key1 value1 :key2 value2)
.
You could read more about property lists or just see a few examples.
Debugging
(trace cow-graze)
: Show the inputs and outputs of every call tocow-graze
.(untrace cow-graze)
Variables
defvar
: A variable expected to be changed, maybe by a human. Does not reset when the file is reloaded. Changing this is not considered a change to the program.defparameter
: A “constant”. Reset when the file is reloaded. Changing this is considered a change to the program.
Utility
Download the base-code.