Find limit of recursion: Difference between revisions

Content added Content deleted
(Added XPL0 example.)
(→‎{{header|Wren}}: Updated code to v0.4.0.)
Line 3,343: Line 3,343:


In Wren a fiber's stack starts small and is increased as required. It appears that the runtime makes no attempt to check for any limitation internally leaving the script to eventually segfault.
In Wren a fiber's stack starts small and is increased as required. It appears that the runtime makes no attempt to check for any limitation internally leaving the script to eventually segfault.
<syntaxhighlight lang="ecmascript">var f
<syntaxhighlight lang="wren">var F = Fn.new { |n|
f = Fn.new { |n|
if (n%500 == 0) System.print(n) // print progress after every 500 calls
if (n%500 == 0) System.print(n) // print progress after every 500 calls
F.call(n + 1)
System.write("") // required to fix a VM recursion bug
f.call(n + 1)
}
}
f.call(1)</syntaxhighlight>
F.call(1)</syntaxhighlight>


{{out}}
{{out}}