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 (cons (make-posn 50 50) (cons (make-posn 50 80) (cons (make-posn 100 80) (cons (make-posn 140 230) (cons (make-posn 180 330) (cons (make-posn 240 220) (cons (make-posn 130 220) empty))))))))
5 12687dd9 2023-08-04 jrmu
6 12687dd9 2023-08-04 jrmu (define (draw-polygon a-poly)
7 12687dd9 2023-08-04 jrmu (cond
8 12687dd9 2023-08-04 jrmu [(empty? (rest a-poly)) true]
9 12687dd9 2023-08-04 jrmu [else (connect-dots (cons (last a-poly) a-poly))]))
10 12687dd9 2023-08-04 jrmu
11 12687dd9 2023-08-04 jrmu (define (connect-dots a-poly)
12 12687dd9 2023-08-04 jrmu (cond
13 12687dd9 2023-08-04 jrmu [(empty? (rest a-poly)) true]
14 12687dd9 2023-08-04 jrmu [else (and
15 12687dd9 2023-08-04 jrmu (draw-solid-line (first a-poly)
16 12687dd9 2023-08-04 jrmu (second a-poly)
17 12687dd9 2023-08-04 jrmu 'black)
18 12687dd9 2023-08-04 jrmu (connect-dots (rest a-poly)))]))
19 12687dd9 2023-08-04 jrmu
20 12687dd9 2023-08-04 jrmu (define (last a-poly)
21 12687dd9 2023-08-04 jrmu (cond
22 12687dd9 2023-08-04 jrmu [(empty? (rest a-poly)) (first a-poly)]
23 12687dd9 2023-08-04 jrmu [else (last (rest a-poly))]))
24 12687dd9 2023-08-04 jrmu (define (add-at-end a-poly first-posn)
25 12687dd9 2023-08-04 jrmu (cond
26 12687dd9 2023-08-04 jrmu [(empty? (rest a-poly)) (first a-poly)]
27 12687dd9 2023-08-04 jrmu [else (cons (add-at-end a-poly first-posn) (cons first-posn empty))]))
28 12687dd9 2023-08-04 jrmu (define (modified-draw-polygon a-poly)
29 12687dd9 2023-08-04 jrmu (cond
30 12687dd9 2023-08-04 jrmu [(empty? (rest a-poly)) true]
31 12687dd9 2023-08-04 jrmu [else (connect-dots (add-at-end a-poly))]))