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-lambda-reader.ss" "lang")((modname |27.1|) (read-case-sensitive #t) (teachpacks ((lib "draw.ss" "teachpack" "htdp") (lib "arrow.ss" "teachpack" "htdp") (lib "gui.ss" "teachpack" "htdp"))) (htdp-settings #(#t constructor repeating-decimal #f #t none #f ((lib "draw.ss" "teachpack" "htdp") (lib "arrow.ss" "teachpack" "htdp") (lib "gui.ss" "teachpack" "htdp")))))
4 ;; sierpinski : posn posn posn -> true
5 ;; Given a, b, and c (posns), draw the triangle specified by the 3 posns and then use generative recursion to draw the nested triangles. Return true once the triangles become too small to draw.
7 (define (sierpinski a b c)
8 (cond
9 [(too small? a b c) true]
10 [else (and (draw-triangle a b c)
11 (sierpinski a a-b a-c)
12 (sierpinski b a-b b-c)
13 (sierpinski c a-c b-c))]))