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 A Web Service. On to Records.
Held Monday, April 30, 2001
Summary
Today we go over some of the key issues from exam 2.
Notes:
Overview
map!
fileand
portinterchangably (-2)
make-string.
(define left-align
(lambda (str width)
(let ((len (string-length str)))
; If the string is too long, chop it!
(if (> len width)
(substring str 0 width)
; Otherwise, add the appropriate number of spaces.
(string-append str
(make-string (- width len) #\space))))))
(apply min (map (compose string-length car) students))
peek-char. Unfortunately, if you're using
read to get each student, the next character after
the last student is a newline, rather than the eof mark.
map!proc. (It should be a
procedure of one parameter; it should be applyable to every
element of vec.)
(define map!
(lambda (proc vec)
(let helper ((hproc proc)
(hvec vec)
(pos 0))
(if (= pos (- (vector-length vec) 1))
(vector-set! vec pos (hproc (vector-ref vec pos)))
(begin
(vector-set! vec pos (hproc (vector-ref vec pos)))
(helper proc vec (+ pos 1)))))))
hproc and
hvec serve (or when you should use one rather
than the other).
hproc and hvec.
let) or
count down, rather than up.
(define map!
(lambda (proc vec)
(let helper ((pos (- (vector-length vec) 1)))
(if (>= pos 0)
(begin
(vector-set! vec pos (proc (vector-ref vec pos)))
(helper proc vec (- pos 1)))))))
(lambda (x) ((cexpt 2) x)) instead of just
(cexpt 2), which was the point of the problem.
ccompose needs
fairly careful preconditions.
c-right-section
(define c-right-section
(lambda (proc)
(lambda (right)
(lambda (left)
((proc right) left)))))
reverse-args
and say something like
proc except the order
of parameters is reversed. That is, (newproc a b)
is the same as (proc b a).
(proc right left)
Back to A Web Service. On to Records.
[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:15:13 2004.
This page may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS151/2001S/outline.49.html.
You may validate
this page's HTML.
The source was last modified Tue Jan 23 16:01:59 2001.