Find limit of recursion: Difference between revisions
Content deleted Content added
m →recursive subroutine: corrected misspelling of personal. |
J: rewrite |
||
Line 754:
=={{header|J}}==
Testing stack depth can be risky because the OS may shut down J in the limiting case. To portably test stack depth it's best to run jconsole and display a count as each stack frame is entered.
This task assumes that all stack frames must be the same size, which is probably not the case:▼
▲
<lang J>(recur=: verb def 'recur smoutput N=:N+1')N=:0</lang>
Note also, that ^: can be used for induction, and does not have stack size limits, though it does require that the function involved is a mathematical function -- and this is not always the case (for example, Markov processes typically use non-functions).▼
This above gives a stack depth of 9998 on one machine.
▲Note also, that ^: can be used for induction, and does not have stack size limits, though it does require that the function involved is a mathematical function of known variables -- and this is not always the case (for example, Markov processes typically use non-functions or "functions of unknown variables").
=={{header|Java}}==
|