Find limit of recursion: Difference between revisions
Content added Content deleted
m (→{{header|REXX}}: added comments to the header section. -- ~~~~) |
m (Added LSL) |
||
Line 777: | Line 777: | ||
test() |
test() |
||
</lang> |
</lang> |
||
=={{header|LSL}}== |
|||
I ran this twice and got 1891 and 1890; probably varies with the number Avatars on a Sim and other variables I can't control. |
|||
Originally I had it without the OwnerSay in the recursive function. Generally, if LSL has a Runtime Error it just shouts on the DEBUG_CHANNEL and skips to the next statement (which would have returned to the next statement in state_entry() said the highest number it had achieved) but, it just shouted "Script run-time error. Object: Stack-Heap Collision" on debug and quit running. |
|||
To test it yourself; rez a box on the ground, and add the following as a New Script. |
|||
<lang LSL>integer iLimit_of_Recursion = 0; |
|||
Find_Limit_of_Recursion(integer x) { |
|||
llOwnerSay("x="+(string)x); |
|||
iLimit_of_Recursion = x; |
|||
Find_Limit_of_Recursion(x+1); |
|||
} |
|||
default { |
|||
state_entry() { |
|||
Find_Limit_of_Recursion(0); |
|||
llOwnerSay("iLimit_of_Recursion="+(string)iLimit_of_Recursion); |
|||
} |
|||
} |
|||
</lang> |
|||
Output: |
|||
<pre> |
|||
[2012/07/07 18:40] Object: x=0 |
|||
[2012/07/07 18:40] Object: x=1 |
|||
[2012/07/07 18:40] Object: x=2 |
|||
... ... ... ... ... |
|||
[2012/07/07 18:41] Object: x=1888 |
|||
[2012/07/07 18:41] Object: x=1889 |
|||
[2012/07/07 18:41] Object: x=1890 |
|||
[2012/07/07 18:41] Object: Object [script:New Script] Script run-time error |
|||
[2012/07/07 18:41] Object: Stack-Heap Collision |
|||
</pre> |
|||
=={{header|Mathematica}}== |
=={{header|Mathematica}}== |