Contents    Page-10    Prev    Next    Page+10    Index   

Binding Lists

A binding is an association between a name and a value.

In Clojure, we can represent a binding as a list:
(list name value ), e.g. (?X 3). We will use names that begin with ? to denote variables.

A set of bindings is represented as a list, called an association list, or alist for short. A new binding can be added by:

(cons (list name value ) binding-list )

A name can be looked up using assocl:

(assocl name binding-list )


(assocl '?y '((?x 3) (?y 4) (?z 5)))
   =  (?y 4)
The value of the binding can be gotten using second:

(second (assocl '?y '((?x 3) (?y 4) (?z 5))))
   =  4