CSC104H1 Lecture Notes - Lecture 6: Sierpinski Triangle, Animage

30 views2 pages
26 Sep 2016
School
Course

Document Summary

; recursion : the sierpinski triangle, part iv (require picturing-programs) ; randomly-colored-triangle : number image (define (randomly-colored-triangle size) (triangle size solid (apply make-color (map random (list 256 256 256))))) ; the function stack" from part i: (define (stack an-image) (above an-image (beside an-image an-image))) ; a variant of the function s" from part ii, using a random coloured base triangle. (define (s-a n) (cond [(= n 0) (randomly-colored-triangle 10)] ; this stacks *one* randomly coloured triangle many times: (s-a 2) ; (stack (stack (s-a 0))) ; if instead of using stack" we use write out the body of stack", we get a different effect: (define (s-b n) (cond [(= n 0) (randomly-colored-triangle 10)] [else (above (s-b (- n 1)) (beside (s-b (- n 1)) (s-b (- n 1))))])) ; the following stacks *three* independently created randomly coloured triangles: (s-b 1) ; (above (s-b 0) (beside (s-b 0) (s-b 0)))

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents