-
Notifications
You must be signed in to change notification settings - Fork 0
/
191.rkt
39 lines (29 loc) · 1.1 KB
/
191.rkt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
;; The first three lines of this file were inserted by DrRacket. They record metadata
;; about the language level of this file in a form that our tools can easily process.
#reader(lib "htdp-beginner-reader.ss" "lang")((modname 191ex) (read-case-sensitive #t) (teachpacks ()) (htdp-settings #(#t constructor repeating-decimal #f #t none #f () #f)))
;; Exercise 191
;; ------------
;; Adapt the second example for the render-poly function to connect-dots.
;; -----------------------------------------------------------------------------
(require 2htdp/image)
(require 2htdp/universe)
(define MT (empty-scene 50 50))
; An NELoP is one of:
; – (cons Posn '())
; – (cons Posn NELoP)
(define square-p
(list
(make-posn 10 10)
(make-posn 20 10)
(make-posn 20 20)
(make-posn 10 20)))
; Image NELoP -> Image
; connects the dots in p by rendering lines in img
(define (connect-dots img p)
MT)
(check-expect (connect-dots MT square-p)
(scene+line
(scene+line
(scene+line MT 20 20 10 20 "red")
20 10 20 20 "red")
10 10 20 10 "red"))