Created
November 2, 2019 17:41
-
-
Save chelseatroy/9b6dfec1a9a1461f8ff24d67c901181d to your computer and use it in GitHub Desktop.
Composing More Procedures
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; 1.43 | |
(define (repeated operation n) | |
(define (operation-iter iterator composed-function) | |
(if (= iterator 1) | |
(lambda(x) (composed-function x)) | |
(operation-iter (- iterator 1) (compose operation composed-function)) | |
)) | |
(operation-iter n operation) | |
) | |
((repeated square 2) 5) ;-----------> 625 | |
; 1.44 | |
(define (smooth f) | |
(lambda (x dx) (/ (+ (f (- x dx)) (f x) (f (+ x dx))) 3)) | |
) | |
((smooth square) 0 4) ;-----------> 10 & 3/4 | |
(repeated ((smooth square) 0 4) 5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment