This is a preliminary draft of the book. The final book will appear with MIT Press in 2001 and will move to its permanent Web site sometime in the fall of 2000.
The Design Recipe for Functions |
---|
Problem Analysis & Data Definition |
Contract, Purpose & Effect Statements, Header |
Examples |
Functiona Template |
Function Definition |
Tests |
This marker refers to teacher hints, which suggest strategies on how to present a section, on how to approach an exercise, or on how to supplement some material. | |
This marker refers to DrScheme hints. The programming environment has been designed with students in mind. The hints suggest how to use it at various stages of the learning process. | |
This marker, placed at the end of exercises, links to on-line solutions. Solutions are available to registered teachers. To find out more about registration, see the book's registration site (not available yet). |
|
|
;; dimensions of traffic light (define WIDTH 50) (define HEIGHT 160) (define BULB-RADIUS 20) (define BULB-DISTANCE 10) ;; the positions of the bulbs (define X-BULBS (quotient WIDTH 2)) (define Y-RED (+ BULB-DISTANCE BULB-RADIUS)) (define Y-YELLOW (+ Y-RED BULB-DISTANCE (* 2 BULB-RADIUS))) (define Y-GREEN (+ Y-YELLOW BULB-DISTANCE (* 2 BULB-RADIUS))) ;; draw the light with the red bulb turned on (start WIDTH HEIGHT) (draw-solid-disk (make-posn X-BULBS Y-RED) BULB-RADIUS RED) (draw-circle (make-posn X-BULBS Y-YELLOW) BULB-RADIUS YELLOW) (draw-circle (make-posn X-BULBS Y-GREEN) BULB-RADIUS GREEN) |
|
(cons 'Mercury empty) |
| ||||||
(cons 'Venus (cons 'Mercury empty)) |
| ||||||
(cons 'Earth (cons 'Venus (cons 'Mercury empty))) |
|
Item | Price | Image |
robot | 29.95 | |
robot | 29.95 | |
robot | 29.95 |
|
Tree A: | Tree B: |
Scheme expression | representation of Scheme expression |
---|---|
3 | 3 |
x | 'x |
(* 3 10) | (make-mul 3 10) |
(+ (* 3 3) (* 4 4)) | (make-add (make-mul 3 3) (make-mul 4 4)) |
(+ (* x x) (* y y)) | (make-add (make-mul 'x 'x) (make-mul 'y 'y)) |
(* 1/2 (* 3 3)) | (make-mul 1/2 (make-mul 3 3)) |
|
(listof number) | -> | (listof number) |
(listof IR) | -> | (listof symbol) |
(number -> number) | (listof number) | -> | (listof number) |
(IR -> symbol) | (listof IR) | -> | (listof symbol) |
number | (listof number) | -> | (listof number) |
number | (listof IR) | -> | (listof IR) |
(number number -> boolean) | number | (listof number) | -> | (listof number) |
(number IR -> boolean) | number | (listof IR) | -> | (listof IR) |
(number X -> boolean) | number | (listof X) | -> | (listof X) |
(number X -> boolean) | number | (listof X) | -> | (listof X) |
|
|
(list 11 8 14 7) | |||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
(list 7 8 11 14) |
list to be sorted | ||
sort process for partition with items smaller than pivot | sort process for partition with items larger than pivot | |
sorted list |
(define hand0 (create-hand 13 spades)) |
(add-at-end! diamonds 1 hand0) | |
|