以下は、スキーム内の関数のリストを指定して関数の合成を返すプロシージャを作成するために行った試みです。私は行き詰まりに達しました。私が試したものは紙の上では理にかなっていますが、どこが間違っているのかわかりません。誰かがヒントを教えてくれますか?
; (compose-all-rec fs) -> procedure
; fs: listof procedure
; return the function composition of all functions in fs:
; if fs = (f0 f1 ... fN), the result is f0(f1(...(fN(x))...))
; implement this procedure recursively
(define compose-all-rec (lambda (fs)
(if (empty? fs) empty
(lambda (fs)
(apply (first fs) (compose-all-rec (rest fs)))
))))
where ((compose-all-rec (list abs inc)) -2) should equal 1