Skip to content

Instantly share code, notes, and snippets.

@pesterhazy
Created April 11, 2021 11:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pesterhazy/b6300066d70220e761aabd73b0f8dab3 to your computer and use it in GitHub Desktop.
Save pesterhazy/b6300066d70220e761aabd73b0f8dab3 to your computer and use it in GitHub Desktop.
Software Design for Flexibility Ch. 2.1.1
(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