Chapter 1, Building Abstractions with Procedures
Section - Formulating Abstractions with Higher-Order Procedures
Exercise 1.43
1
2
3
4
5
6
(define (repeated f n)
(define (repeat rs k)
(if (= k 1) rs (repeat (compose rs f) (dec k)))
)
(repeat f n)
)
Output:
1
2
> ((repeated square 2) 5)
625
As mentioned in the problem we can see that $5^{(2^2)} = 5^4 = 625$ i.e. number five is raised to the $2^n$-th power where $n$ is the number of repetitions.