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 (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))))))))
6 (define (draw-polygon a-poly)
7 (cond
8 [(empty? (rest a-poly)) true]
9 [else (connect-dots (cons (last a-poly) a-poly))]))
11 (define (connect-dots a-poly)
12 (cond
13 [(empty? (rest a-poly)) true]
14 [else (and
15 (draw-solid-line (first a-poly)
16 (second a-poly)
17 'black)
18 (connect-dots (rest a-poly)))]))
20 (define (last a-poly)
21 (cond
22 [(empty? (rest a-poly)) (first a-poly)]
23 [else (last (rest a-poly))]))
24 (define (add-at-end a-poly first-posn)
25 (cond
26 [(empty? (rest a-poly)) (first a-poly)]
27 [else (cons (add-at-end a-poly first-posn) (cons first-posn empty))]))
28 (define (modified-draw-polygon a-poly)
29 (cond
30 [(empty? (rest a-poly)) true]
31 [else (connect-dots (add-at-end a-poly))]))