Functional Problem Solving (CSC 151 2013F) : EBoards
Primary: [Front Door] [Schedule] - [Academic Honesty] [Disabilities] [Email] [FAQ] [IRC] [Teaching & Learning] [Grading]
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 (2010F)] [Weinman (2012F)]
Misc: [SamR] [Glimmer Labs] [CS@Grinnell] [Grinnell] [Issue Tracker (Course)]
Overview
Admin
Exam 2 Questions
Pre Quiz Questions
Can you help me with named let? "I need to create a helper with these parameters (p1 p2), and I need to call the helper with values v1 v2." Here's the syntax
(let helper ([p1 v1]
[p2 v2])
instructions)
(let helper ([so-far 0]
[lst lst])
This corresponds to a lambda expression AND A CALL to the lambda
(letrec ([helper (lambda (p1 p2) instructions)]) (helper v1 v2))
A big difference for the named let version is, while you can call it recursively, you can't access the procedure outside the body of the let.
Geometric art had cond expressions without an else.
(cond [(> n 0) (image-draw-line! ...) (kernel ... (- n 1))])
Meaning: If no tests succeed, just do nothing (other than the tests).
We should have used
(when (> n 0) (image-draw-line! ...) (kernel ... (- n 1)))
Can we have a formula for letrec as a kernel
(define PROC (letrec ([kernel (lambda (p1 p2) BODY)]) (lambda (a0 a1) (cond [(fails-precondition? a0 a1) (error "You seem to misunderstand.")] [(fails-another-precondition? a0) (error "Maybe Sam misunderstands.")] [else (kernel a0 a1)]))))
Types we've seen so far include ...
Two new types: characters and strings
Do it on your own. Have a good weekend.
Primary: [Front Door] [Schedule] - [Academic Honesty] [Disabilities] [Email] [FAQ] [IRC] [Teaching & Learning] [Grading]
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 (2010F)] [Weinman (2012F)]
Misc: [SamR] [Glimmer Labs] [CS@Grinnell] [Grinnell] [Issue Tracker (Course)]
Samuel A. Rebelsky, rebelsky@grinnell.edu
Copyright (c) 2007-2013 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.