Blame


1 12687dd9 2023-08-04 jrmu ;; The first three lines of this file were inserted by DrScheme. They record metadata
2 12687dd9 2023-08-04 jrmu ;; about the language level of this file in a form that our tools can easily process.
3 12687dd9 2023-08-04 jrmu #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 12687dd9 2023-08-04 jrmu (define (make-coord x y)
5 12687dd9 2023-08-04 jrmu (local ((define x0 x)
6 12687dd9 2023-08-04 jrmu (define y0 y)
7 12687dd9 2023-08-04 jrmu (define (set-x new-x) (set! x0 new-x))
8 12687dd9 2023-08-04 jrmu (define (set-y new-y) (set! y0 new-y)))
9 12687dd9 2023-08-04 jrmu (lambda (op)
10 12687dd9 2023-08-04 jrmu (op x y set-x set-y))))
11 12687dd9 2023-08-04 jrmu
12 12687dd9 2023-08-04 jrmu (define (coord-x acoord)
13 12687dd9 2023-08-04 jrmu (acoord (lambda (x y set-x set-y) x)))
14 12687dd9 2023-08-04 jrmu (define (coord-y acoord)
15 12687dd9 2023-08-04 jrmu (acoord (lambda (x y set-x set-y) y)))
16 12687dd9 2023-08-04 jrmu (define (coord-x! acoord new-x)
17 12687dd9 2023-08-04 jrmu (acoord (lambda (x y set-x set-y) (set-x new-x))))
18 12687dd9 2023-08-04 jrmu (define (coord-y! acoord new-y)
19 12687dd9 2023-08-04 jrmu (acoord (lambda (x y set-x set-y) (set-y new-y))))
20 12687dd9 2023-08-04 jrmu
21 12687dd9 2023-08-04 jrmu (define acoord (make-coord 5 6))
22 12687dd9 2023-08-04 jrmu (coord-x! acoord 3)
23 12687dd9 2023-08-04 jrmu (coord-y! acoord 2)
24 12687dd9 2023-08-04 jrmu (coord-x acoord)
25 12687dd9 2023-08-04 jrmu (coord-y acoord)
26 12687dd9 2023-08-04 jrmu
27 12687dd9 2023-08-04 jrmu #|
28 12687dd9 2023-08-04 jrmu Demonstrate how to modify a structure like (ffm-make-posn 3 4) so that its y field contains 5. Solution
29 12687dd9 2023-08-04 jrmu |#