Created
April 11, 2021 11:46
-
-
Save pesterhazy/b6300066d70220e761aabd73b0f8dab3 to your computer and use it in GitHub Desktop.
Software Design for Flexibility Ch. 2.1.1
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
(define (identity x) x) | |
(define (compose f g) | |
(define (the-composition . args) | |
(f (apply g args))) | |
the-composition) | |
(define ((iterate n) f) | |
(if (= n 0) | |
identity | |
(compose f ((iterate (- n 1)) f)))) | |
(define (square n) (* n n)) | |
(((iterate 3) square) 5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment