sicp-solutions/chapter-1/ex-1.41.scm

12 lines
466 B
Scheme

#lang sicp
(define (double f)
(lambda (x) (f (f x))))
; double doubles the function application, so when you do
; (double double) you actually get back a function which performs
; a (double (double f)) on a given f, in other words, it
; applies f 4 times. When we do this three times,
; (double (double double)) gives us a function, that for f gives
; (double (double (double (double f)))), which actually
; applies f sixteen times,
; so the result is 5+16 = 21.