Of course. A sequel can do anything! However, you end up inventing one of two things: a loop or a function call. On my machine, which by default performs tail call optimization, tail recursion with the / cc call is not optimized. The program quickly fades, as each callcc seems to grab the entire call stack. This code is broken, here is the / cc call loop:
def fact( n ) (n, f, k) = callcc { |k| [ n, 1, k ] } if ( n == 0 ) then return f else k.call n-1, n*f, k end end
Note: earlier I forgot that call / cc does not just initiate the chain to continue the transfer and got confused about the need for recursion, so the comments are below.
source share