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
Reading: Local Procedure Bindnigs. Lab: Local Procedure Bindings. Back to Simulation. On to Procedures as Values.
Held Wednesday, March 14, 2001
Summary
Today we consider techniques for defining local procedures, procedures that are only available to select other procedures.
Notes
let. I hope to have them ready for tomorrow.
count-odd-rolls question. This person,
like many of you, reflected on the possibility of using
roll-die as a helper. Unfortunately, the solution
does much more work than it needs to
(define count-odd-rolls
(lambda (n)
; If you roll 0 dice, then you can have 0 odd numbers.
(if (= n 0) 0
; Otherwise ...
(let ((dice (roll-dice n))) ; Roll some dice
; See if the first one is odd
(if (odd? (car dice))
; If so, count it and then do the rest
(+ 1 (count-odd-rolls (- n 1)))
; Otherwise, just cound the remaining odd
; rolls
(count-odd-rolls (- n 1)))))))
roll-dice to print a short note each time it
is called.
let.
Overview
let and let*.
let nor let* works for
recursive procedures.
letrec.
Friday, 12 January 2001
Wednesday, 14 March 2001
Back to Simulation. On to Procedures as Values.
[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:02 2004.
This page may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS151/2001S/outline.30.html.
You may validate
this page's HTML.
The source was last modified Wed Mar 14 08:17:13 2001.