Find limit of recursion: Difference between revisions

Content added Content deleted
(→‎{{header|OCaml}}: make it more readable with some indentation)
(→‎{{header|gnuplot}}: incorporate the "try" initialization in the code rather than command line)
Line 573: Line 573:


=={{header|gnuplot}}==
=={{header|gnuplot}}==
<lang gnuplot># Put this in a file recurse.gnuplot and run as
<lang gnuplot># Put this in a file foo.gnuplot and run as
# gnuplot -e try=1 recurse.gnuplot
# gnuplot foo.gnuplot


# probe by 1 up to 1000, then by 1% increases
# probe by 1 up to 1000, then by 1% increases
if (! exists("try")) { try=0 }
try=(try<1000 ? try+1 : try*1.01)
try=(try<1000 ? try+1 : try*1.01)


Line 587: Line 588:


<pre>try recurse 251
<pre>try recurse 251
"/so/rosetta/recurse.gnuplot", line 2499: recursion depth limit exceeded</pre>
"/tmp/foo.gnuplot", line 2760: recursion depth limit exceeded</pre>


Gnuplot 4.4 and earlier has no limit except the C stack, giving a segv or whatever eventually.
Gnuplot 4.4 and earlier has no limit except the C stack, giving a segv or whatever eventually.