Fundamentals of CS I (CS151 2001S) : Outlines
[Current]
[Discussions]
[Glance]
[Honesty]
[Instructions]
[Links]
[News]
[Search]
[Syllabus]
Primary
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Outlines]
[Quizzes]
[Readings]
[Reference]
Sets
[Blackboard]
[Scheme Report]
[SamR's Schedule]
[Rebelsky/Fall 2000]
[Walker/Fall2000]
[Stone/Spring2000]
Links
Back to Association Lists. On to Preconditions and Postconditions.
Held Friday, February 23, 2001
Summary
Today we pause to reflect on some of the more difficult problems we've worked on recently and to consider the examination.
Assignments
Due
Notes
Overview
assoc procedure can
return an entry from the association list or #f.
assoc-all
procedure (that returns a list of all the matching entries)
to return #f when 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)))))))
Friday, 12 January 2001
Thursday, 22 February 2001
Saturday, 24 February 2001
Back to Association Lists. On to Preconditions and Postconditions.
[Current]
[Discussions]
[Glance]
[Honesty]
[Instructions]
[Links]
[News]
[Search]
[Syllabus]
Primary
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Outlines]
[Quizzes]
[Readings]
[Reference]
Sets
[Blackboard]
[Scheme Report]
[SamR's Schedule]
[Rebelsky/Fall 2000]
[Walker/Fall2000]
[Stone/Spring2000]
Links
Disclaimer: I usually create these pages on the fly. This means that they are rarely proofread and may contain bad grammar and incorrect details. It also means that I may update them regularly (see the history for more details). Feel free to contact me with any suggestions for changes.
This page was generated by Siteweaver on Wed May 5 12:14:56 2004.
This page may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS151/2001S/outline.20.html.
You may validate
this page's HTML.
The source was last modified Sat Feb 24 07:18:37 2001.