Find limit of recursion: Difference between revisions
→{{header|Phix}}: added a saner test
(Added missing parameter type to compile with Nim 1.4. Changed comment to describe behavior with this version.) |
(→{{header|Phix}}: added a saner test) |
||
Line 2,165:
=={{header|Phix}}==
On a 32-bit version the limit is an impressive
<lang Phix>atom t1 = time()+1
Line 2,183:
recurse()</lang>
{{out|output|text= 32 bit}}
<pre>
C:\Program Files (x86)\Phix>p e01
Line 2,224:
C:\Program Files (x86)\Phix>
</pre>
=== saner ===
The following much more safely merely tests it can reach 20,000,000, plus however far it gets in the last whole-second
<lang Phix>atom t1 = time()+1
integer depth = 0, depth_blown = false
string btd = "building"
procedure recurse()
if time()>t1 then
printf(1,"depth: %d (%s)\n",{depth,btd})
if depth>20_000_000 then
depth_blown = true
btd = "tearing down"
end if
t1 = time()+1
end if
if depth_blown then
depth -= 1
else
depth += 1
recurse() -- (build)
recurse() -- (tear down)
end if
end procedure
recurse()</lang>
{{out}}
<pre>
depth: 8857573 (building)
depth: 17197111 (building)
depth: 25309477 (building)
depth: 20023696 (tearing down)
depth: 14825154 (tearing down)
depth: 9601027 (tearing down)
depth: 3725849 (tearing down)
</pre>
=={{header|PHP}}==
|