CS212 Exams
Fall 1996 - Prelim 1

Generic Functions


This problem concerns generic functions. Consider the following two generic functions:
(defgeneric (f a))

(defmethod (f (a <object>)) (print "apple"))

(defmethod (f (a <nurble>)) (print "lemon"))

(defgeneric (g b))

(defmethod (g (b <glorp>)) (print "diamond"))

(defmethod (g (b <foo>)) (print "sapphire"))

(defmethod (g (b <object>)) (print "ruby"))

Assume that the types <nurble> , <glorp> , <foo> and <bar> have been defined such that the following output is generated:

(f (make-glorp)) = "apple"

(f (make-foo)) = "lemon"

(f (make-bar)) = "lemon"

(g (make-bar)) = "ruby"

What are the definitions of the classes <nurble> , <glorp> , <foo> and <bar> that must have been defined to obtain this output?






Solution

Return to CS 212 Prelim 1 - Fall 1996