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-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 (define MRPOLY (list (make-posn 20 30)
5 (make-posn 30 40)
6 (make-posn 50 90)
7 (make-posn 100 40)
8 (make-posn 150 80)
9 (make-posn 240 120)
10 (make-posn 40 10)))
12 (define (modified-draw-polygon a-poly)
13 (local ((define (draw-polygon a-poly)
14 (cond
15 [(empty? (rest a-poly)) true]
16 [else (connect-dots (cons (last a-poly) a-poly))]))
18 (define (connect-dots a-poly)
19 (cond
20 [(empty? (rest a-poly)) true]
21 [else (and
22 (draw-solid-line (first a-poly)
23 (second a-poly)
24 'black)
25 (connect-dots (rest a-poly)))]))
27 (define (last a-poly)
28 (cond
29 [(empty? (rest a-poly)) (first a-poly)]
30 [else (last (rest a-poly))]))
31 (define (add-at-end a-poly first-posn)
32 (cond
33 [(empty? (rest a-poly)) (first a-poly)]
34 [else (cons (add-at-end a-poly first-posn) (cons first-posn empty))]))
35 (define (modified-draw-polygon a-poly)
36 (cond
37 [(empty? (rest a-poly)) true]
38 [else (connect-dots (add-at-end a-poly (first a-poly)))])))
39 (modified-draw-polygon a-poly)))
41 (start 500 500)
42 (modified-draw-polygon MRPOLY)