I am calculating a continuous fraction (The golden ratio for now) and this is my code:
(define cont-frac
(lambda (n d k)
(define res (+ (/ n d) n))
(if (= k 0)
res
(cont-frac n res (- k 1)))))
And i call it like this:
(cont-frac 1.0 1.0 100)
which returns 1.618033988749895.
But my teacher wants me to call it like this:
(cont-frac (lambda (x) 1.0)
(lambda (x) 1.0)
100)
I am new to R5RS and stuff like this is not very clear to me yet. Why would I want to call it like this? How do i code my cont-frac function to allow this? Not sure if this info is helpful or not, but I am eventually going to want to use a function as one of the parameters.
Thanks in advance.