1. Engineering
  2. Computer Science
  3. exercise 2711 develop the functions 1 drawtriangle posn posn...

Question: exercise 2711 develop the functions 1 drawtriangle posn posn...

Question details

Exercise 27.1.1 Develop the functions 1. ; draw-triangle: posn posn posntrue 2. ; too-small? Use the teachpack draw.ss to test the code. For a first test of the com- posn posn posn bool to complete the definitions in figure 72. plete function, use the following definitions: (define A (make-posn 200 0) (define B (make-posn 27 300)) (define C (make-posn 373 300)
:i sierpinski : posn posn posn true ;i to draw a Sierpinski triangle down at a, b, and c, assuming it is large enough (define (sierpinski a b c) (cond [(too-small? a b c) true] else (local (define a-b (mid-point a b)) (define b-c (mid-point bc) (define c-a (mid-point a c)) (and draw-triangle a b c) (sierpinski a a-b c-a) (sierpinski ba-bb-c) (sierpinski c c-a b-c))I) ; mid-point : posn posn posn (define (mid-point a-posn b-posn) to compute the mid-point between a-posn and b-posn (make-posn (mid (posn-x a-posn) (posn-x b-posn)) (mid (posn-y a-posn) (posn-y b-posn) ;; mid : number number → number : to compute the average of x andy (define (mid x y) Figure 72: The Sierpinski algorithm
Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution