CS151.02 2010S Functional Problem Solving
[Skip to Body]
Primary:
[Front Door]
[Schedule]
-
[Academic Honesty]
[Instructions]
Current:
[Outline]
[EBoard]
[Reading]
[Lab]
-
[Assignment]
[Quiz]
Groupings:
[Assignments]
[EBoards]
[Examples]
[Exams]
[Handouts]
[Labs]
[Outlines]
[Projects]
[Quizzes]
[Readings]
References:
[A-Z]
[By Topic]
-
[Scheme Report (R5RS)]
[R6RS]
[TSPL4]
Related Courses:
[CSC151.02 2009S (Weinman)]
[CSC151.02 2009S (Davis)]
[CSC151 2009F (Rebelsky)]
Misc:
[SamR]
[MediaScript]
[GIMP]
Back to Pause for Breath. On to What is Computer Science? Revisited.
This outline is also available in PDF.
Held: Monday, May 10, 2010
Summary: We begin to explore objects in Scheme. Objects encapsulate data and the procedures that work with those data.
Related Pages:
Notes:
Overview:
(define greeter (lambda (message) (cond ((eq? message ':enter) (display "Hello") (newline)) ((eq? message ':leave) (display "Goodbye") (newline)) (else (error "Unknown Message")))))
> (greeter ':enter)Hello > (greeter ':leave)Goodbye > (greeter ':sleep)Unknown Message
let
outside the lambda
for the procedure.
(define fixed-value (let ((value 5)) (lambda (message) (cond ((eq? message ':get) value) (else (error "fixed-value:" "unknown message"))))))
(define incrementable-value (let ((value (vector 0))) (lambda (message) (cond ((eq? message ':get) (vector-ref value 0)) ((eq? message ':add1!) (vector-set! value 0 (+ 1 (vector-ref value 0)))) (else (error "fixed-value:" "unknown message"))))))
> (incrementable-value ':get) 0 > (incrementable-value ':add1!) > (incrementable-value ':get) 1
Back to Pause for Breath. On to What is Computer Science? Revisited.
[Skip to Body]
Primary:
[Front Door]
[Schedule]
-
[Academic Honesty]
[Instructions]
Current:
[Outline]
[EBoard]
[Reading]
[Lab]
-
[Assignment]
[Quiz]
Groupings:
[Assignments]
[EBoards]
[Examples]
[Exams]
[Handouts]
[Labs]
[Outlines]
[Projects]
[Quizzes]
[Readings]
References:
[A-Z]
[By Topic]
-
[Scheme Report (R5RS)]
[R6RS]
[TSPL4]
Related Courses:
[CSC151.02 2009S (Weinman)]
[CSC151.02 2009S (Davis)]
[CSC151 2009F (Rebelsky)]
Misc:
[SamR]
[MediaScript]
[GIMP]
Disclaimer:
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 Tue May 11 09:03:17 2010.
The source to the document was last modified on Thu Jan 21 13:05:10 2010.
This document may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS151/2010S/Outlines/outline.53.html
.
You may wish to
validate this document's HTML
;
;
http://creativecommons.org/licenses/by-nc/2.5/
or send a letter to Creative Commons, 543 Howard Street, 5th Floor,
San Francisco, California, 94105, USA.