Anonymous user
Talk:Anonymous recursion: Difference between revisions
J Example Correction
(J Example) |
(J Example Correction) |
||
Line 115:
:The J solution is incorrect because it does not check for a negative sign, it simply implements the fibonacci function. Using $: is problematic because it is a reference to the largest verb which means that it will re-execute the entire function including the check if such a check is included. I have fixed the Mathematica example so that the check is performed only once, #0 is local to the anonymous function it is referenced in, this is the fibonacci function and not the function with the check. --[[User:Zeotrope|Zeotrope]] 16:18, 8 January 2011 (UTC)
::Since the J solution acts like an identity when called with negative arguments the check for negative numbers can be performed after the fibonacci function is called, signalling a domain error if the result is negative: <lang J>fibN =:
|