I kinda understand how to convert elementary functions such as arithmetics to continuation-passing style in Scheme.
But what if the function involves recursion?
For example,
(define funname
(lambda (arg0 arg1)
(and (some procedure)
(funname (- arg0 1) arg1))))
Please give me advices.
Thank you in advance.
You are lacking a base case, which is why the only explicit call to the continuation is
(k #f). If you have a base case, then you’d pass the base case return value to the continuation, also. For example: