Binding Lists

A binding is a correspondence of a name and a value. In Lisp, it is conventional to represent a binding as a cons:
(cons name value )

The binding will appear in dotted pair notation, i.e., it is printed with a dot between name and value:
(?X . 3)
If the value is a list, the dot and parentheses will cancel:
(?X . (SIN THETA)) will print as (?X SIN THETA) .

A set of bindings is represented as a list, called an association list, or alist for short. A new binding can be added by:
(push (cons name value ) binding-list )

A name can be looked up using assoc:
(assoc name binding-list )

(assoc '?y '((?x . 3) (?y . 4) (?z . 5)))
   =  (?Y . 4)
The value of the binding can be gotten using cdr:

(cdr (assoc '?y '((?x . 3) (?y . 4) (?z . 5))))
   =  4

Contents    Page-10    Prev    Next    Page+10    Index