CSC104H1 Lecture 7: Repeated-Transformation.IV

18 views1 pages
26 Sep 2016
School
Course

Document Summary

; repeated : function any number list. ; (repeated f a n)" produces (list a (f a) (f (f a)) )" with n" elements. (define (repeated f a n) (cond [(= n 1) (list a)] [else (list* a (repeated f (f a) (- n 1)))])) ; the function add1" adds 1 to a number. (check-expect (add1 104) 105) ; repeatedly add 1 to 0 to produce 4 numbers: (check-expect (repeated add1 0 4) ; (list a (f a) (f (f a)) (f (f (f a)))) (list 0 (add1 0) (add1 (add1 0)) (add1 (add1 (add1 0))))) (check-expect (repeated add1 0 4) (list 0 1 2 3)) ; let"s make a function that produces an image from a number. (require picturing-programs) ; rotated-star : number image (define (rotated-star a) (rotate a (star 50 solid maroon))) ; we can animate repeated processes that produce values that aren"t images, if we use a function.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents