Functional Problem Solving (CSC 151 2014S) : Outlines
Primary: [Front Door] [Schedule] - [Academic Honesty] [Disabilities] [Email] - [FAQ] [Teaching & Learning] [Grading] [Rubric] - [Calendar]
Current: [Assignment] [EBoard] [Lab] [Outline] [Partners] [Reading]
Sections: [Assignments] [EBoards] [Examples] [Handouts] [Labs] [Outlines] [Partners] [Readings]
Reference: [Setup] - [Functions A-Z] [Functions By Topic] - [Racket] [Scheme Report (R5RS)] [R6RS] [TSPL4]
Related Courses: [Davis (2013F)] [Rebelsky (2010S)] [Rebelsky (2013F)] [Weinman (2012F)] [Weinman (2014S)]
Misc: [SamR] [Glimmer Labs] [CS@Grinnell] [Grinnell] [Issue Tracker (Course)]
Held: Friday, 2 May 2014
Back to Outline 51 - Project Assessment: Algorithms. On to Outline 53 - Objects in Scheme, Continued.
Summary
We begin to explore objects in Scheme. Objects encapsulate data and the procedures that work with those data.
Related Pages
Overview
Administrivia
(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
Primary: [Front Door] [Schedule] - [Academic Honesty] [Disabilities] [Email] - [FAQ] [Teaching & Learning] [Grading] [Rubric] - [Calendar]
Current: [Assignment] [EBoard] [Lab] [Outline] [Partners] [Reading]
Sections: [Assignments] [EBoards] [Examples] [Handouts] [Labs] [Outlines] [Partners] [Readings]
Reference: [Setup] - [Functions A-Z] [Functions By Topic] - [Racket] [Scheme Report (R5RS)] [R6RS] [TSPL4]
Related Courses: [Davis (2013F)] [Rebelsky (2010S)] [Rebelsky (2013F)] [Weinman (2012F)] [Weinman (2014S)]
Misc: [SamR] [Glimmer Labs] [CS@Grinnell] [Grinnell] [Issue Tracker (Course)]
Samuel A. Rebelsky, rebelsky@grinnell.edu
Copyright (c) 2007-2014 Janet Davis, Samuel A. Rebelsky, and Jerod Weinman. (Selected materials are copyright by John David Stone or Henry Walker and are used with permission.)

This work is licensed under a Creative Commons Attribution 3.0 Unported License. To view a copy of this
license, visit http://creativecommons.org/licenses/by-nc/3.0/
or send a letter to Creative Commons, 543 Howard Street, 5th Floor,
San Francisco, California, 94105, USA.