next up previous
Next: Abstraction Up: Functions and Relations Previous: Function and Relation


If denotes a relation, then the sentence (holds ... ) is true if and only if the list of objects denoted by ,..., is a member of that relation.

(defrelation holds (?r @args) := (and (relation ?r) (member (listof @args) ?r)))

If denotes a function with a value for the objects denoted by ,..., , then the term (value ... ) denotes the value of applying that function to the objects denoted by ,...,. Otherwise, the value is undefined.

(deffunction value (?f @args) := (if (and (function ?f) (member ?l ?f) (= (butlast ?l) (listof @args))) (last ?l)))

(deffunction apply (?f ?l) := (if (and (function ?f) (= ?l (listof @args))) (value ?f @args)))

(deffunction map (?f ?l) := (if (null ?l) (list) (cons (value ?f (first ?l)) (map ?f (rest ?l)))))

Vishal I. Sikka
Wed Dec 7 13:23:42 PST 1994