Held Wednesday, November 27, 2002
Today we pause to reflect on some of the more difficult problems we've worked on recently and to consider the examination.
assocprocedure can return an entry from the association list or
assoc-allprocedure (that returns a list of all the matching entries) to return
#fwhen there are no matching entires.
assoc-all, in which you're supposed to return a list of all the matching entries, it seems natural to me to return the empty list when nothing matches, since that list contains all the matching entries.
(define assoc-all (lambda (key database) ; Nothing can be in the empty database, so return false. (if (null? database) #f ; If we match the car of the database, look in the rest. (if (equal? key (caar database) ; If the key does not appear any more in the database ; make a list of just the one value we've seen (if (not (assoc-all key (cdr database))) (list (car database)) ; Otherwise, attach the matched entry to ; the remaining matched entries (cons (car database) (assoc-all key (cdr database)))) ; We didn't match the car, so just look in the rest (assoc-all key (cdr database)))))))
Thursday, 29 August 2002 [Samuel A. Rebelsky]
Tuesday, 26 November 2002 [Samuel A. Rebelsky]
Monday, 2 December 2002 [Samuel A. Rebelsky]
I usually create these pages
on the fly, which means that I rarely
proofread them and they may contain bad grammar and incorrect details.
It also means that I tend to update them regularly (see the history for
more details). Feel free to contact me with any suggestions for changes.
This document was generated by
Siteweaver on Mon Dec 2 08:42:09 2002.
The source to the document was last modified on Mon Dec 2 08:33:34 2002.
This document may be found at