Last active
November 2, 2019 17:40
-
-
Save chelseatroy/a8070a5cec95d20f3550334d0981fab6 to your computer and use it in GitHub Desktop.
Composing Procedures
This file contains hidden or 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.41 | |
(define (double f) | |
(lambda (x) (f(f x)))) | |
(define (add-2-to x) (+ 2 x)) | |
(define (inc x) (+ 1 x)) | |
(define (square x) (* x x)) | |
((double add-2-to) 3) | |
(((double (double double)) inc) 5) ;---> 21 WHY IS THIS 16 TIMES AND NOT 8 TIMES? | |
; 1.42 | |
(define (compose f g) | |
(lambda (x) (f (g x)))) | |
((compose add-2-to inc) 4) ;-----------> 7 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment