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) (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 n) (compose f (repeat-inner f (+ cur-n 1)))f )) (repeat-inner f 1))