Solution to SICP Exercise 1.43

Structure and Interpretation of Computer Programs

Solution to Exercise 1.43:

(define (compose f g)
(lambda (x) (f (g x))))
(define (inc i) (+ i 1))

(define (repeated f n)
(define (iter i result)
(if (= i n)
result
(iter (inc i) (compose f result))))
(iter 1 f))

%d bloggers like this: