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