Anonymous recursion: Difference between revisions

Content added Content deleted
Line 464: Line 464:
A := if type(A) == "list" then A[1]
A := if type(A) == "list" then A[1]
return (@A, A) # prime and return
return (@A, A) # prime and return
end</lang>

For reference, here is the non-cached version:
<lang unicon>procedure fib(n)
local source, i
if type(n) == "integer" & n >= 0 then
return n @ makeProc {{
i := @(source := &source)
if i = (0|1) then i@source
((i-1)@makeProc(^&current) + (i-2)@makeProc(^&current)) @ source
}}
end</lang>
end</lang>