Exercise 1.43 is the continuation of the previous two questions. Exercise requires us to define a repeat f n, where f is a single parameter process, the question requires that we use the repeat Process f to call the process n times. Note that it is nested call n times rather than consecutive call n times. That is to say, the result should be (f (... (F x )...))), Instead of (begin (f x )... (F x )).
The question also reminds us to use the compose method defined in exercise 1.42.
If you think about it, this can be done through recursive calling, that is, (repeat f n) equals (compose f (repeat f (-n 1 )), that is to say, n nested calls f can be converted to (f (<n-1 nested calls f )).
After understanding this, it is easier to control the end of recursive calls. The Code is as follows:
(Define (repeat f n) (define (repeat-inner f cur-n) (if (<cur-n) (compose f (repeat-inner f (+ cur-n 1) (repeat-inner f 1 ))