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-intermediate-reader.ss" "lang")((modname 18.1.8) (read-case-sensitive #t) (teachpacks ((lib "draw.ss" "teachpack" "htdp"))) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ((lib "draw.ss" "teachpack" "htdp")))))
4 12687dd9 2023-08-04 jrmu (define MRPOLY (list (make-posn 20 30)
5 12687dd9 2023-08-04 jrmu (make-posn 30 40)
6 12687dd9 2023-08-04 jrmu (make-posn 50 90)
7 12687dd9 2023-08-04 jrmu (make-posn 100 40)
8 12687dd9 2023-08-04 jrmu (make-posn 150 80)
9 12687dd9 2023-08-04 jrmu (make-posn 240 120)
10 12687dd9 2023-08-04 jrmu (make-posn 40 10)))
11 12687dd9 2023-08-04 jrmu
12 12687dd9 2023-08-04 jrmu (define (modified-draw-polygon a-poly)
13 12687dd9 2023-08-04 jrmu (local ((define (draw-polygon a-poly)
14 12687dd9 2023-08-04 jrmu (cond
15 12687dd9 2023-08-04 jrmu [(empty? (rest a-poly)) true]
16 12687dd9 2023-08-04 jrmu [else (connect-dots (cons (last a-poly) a-poly))]))
17 12687dd9 2023-08-04 jrmu
18 12687dd9 2023-08-04 jrmu (define (connect-dots a-poly)
19 12687dd9 2023-08-04 jrmu (cond
20 12687dd9 2023-08-04 jrmu [(empty? (rest a-poly)) true]
21 12687dd9 2023-08-04 jrmu [else (and
22 12687dd9 2023-08-04 jrmu (draw-solid-line (first a-poly)
23 12687dd9 2023-08-04 jrmu (second a-poly)
24 12687dd9 2023-08-04 jrmu 'black)
25 12687dd9 2023-08-04 jrmu (connect-dots (rest a-poly)))]))
26 12687dd9 2023-08-04 jrmu
27 12687dd9 2023-08-04 jrmu (define (last a-poly)
28 12687dd9 2023-08-04 jrmu (cond
29 12687dd9 2023-08-04 jrmu [(empty? (rest a-poly)) (first a-poly)]
30 12687dd9 2023-08-04 jrmu [else (last (rest a-poly))]))
31 12687dd9 2023-08-04 jrmu (define (add-at-end a-poly first-posn)
32 12687dd9 2023-08-04 jrmu (cond
33 12687dd9 2023-08-04 jrmu [(empty? (rest a-poly)) (first a-poly)]
34 12687dd9 2023-08-04 jrmu [else (cons (add-at-end a-poly first-posn) (cons first-posn empty))]))
35 12687dd9 2023-08-04 jrmu (define (modified-draw-polygon a-poly)
36 12687dd9 2023-08-04 jrmu (cond
37 12687dd9 2023-08-04 jrmu [(empty? (rest a-poly)) true]
38 12687dd9 2023-08-04 jrmu [else (connect-dots (add-at-end a-poly (first a-poly)))])))
39 12687dd9 2023-08-04 jrmu (modified-draw-polygon a-poly)))
40 12687dd9 2023-08-04 jrmu
41 12687dd9 2023-08-04 jrmu (start 500 500)
42 12687dd9 2023-08-04 jrmu (modified-draw-polygon MRPOLY)