Monday, January 19, 2009

Ch2, Ex11

Kernel transform of IsEven:

proc {IsEven X ?R}
local T in
T = X==0
if T then true else S=X-1 in {IsOdd S R} end
end
end

this is clearly tail recursive, similarly we can see IsOdd is also tail recursive, hence calls {IsOdd N} and {IsEven N} will execute with constant stack size.

No comments:

Post a Comment