Blob


1 ;; The first three lines of this file were inserted by DrScheme. They record metadata
2 ;; about the language level of this file in a form that our tools can easily process.
3 #reader(lib "htdp-advanced-reader.ss" "lang")((modname |40.2|) (read-case-sensitive #t) (teachpacks ((lib "guess-gui.ss" "teachpack" "htdp") (lib "guess.ss" "teachpack" "htdp") (lib "gui.ss" "teachpack" "htdp") (lib "draw.ss" "teachpack" "htdp"))) (htdp-settings #(#t constructor repeating-decimal #t #t none #f ((lib "guess-gui.ss" "teachpack" "htdp") (lib "guess.ss" "teachpack" "htdp") (lib "gui.ss" "teachpack" "htdp") (lib "draw.ss" "teachpack" "htdp")))))
4 (define (make-coord x y)
5 (local ((define x0 x)
6 (define y0 y)
7 (define (set-x new-x) (set! x0 new-x))
8 (define (set-y new-y) (set! y0 new-y)))
9 (lambda (op)
10 (op x y set-x set-y))))
12 (define (coord-x acoord)
13 (acoord (lambda (x y set-x set-y) x)))
14 (define (coord-y acoord)
15 (acoord (lambda (x y set-x set-y) y)))
16 (define (coord-x! acoord new-x)
17 (acoord (lambda (x y set-x set-y) (set-x new-x))))
18 (define (coord-y! acoord new-y)
19 (acoord (lambda (x y set-x set-y) (set-y new-y))))
21 (define acoord (make-coord 5 6))
22 (coord-x! acoord 3)
23 (coord-y! acoord 2)
24 (coord-x acoord)
25 (coord-y acoord)
27 #|
28 Demonstrate how to modify a structure like (ffm-make-posn 3 4) so that its y field contains 5. Solution
29 |#