Re: Recursion limit: a good idea to ignore?

*To*: mathgroup at smc.vnet.net*Subject*: [mg82239] Re: Recursion limit: a good idea to ignore?*From*: Szabolcs Horvát <szhorvat at gmail.com>*Date*: Tue, 16 Oct 2007 03:22:30 -0400 (EDT)*References*: <feutsm$st$1@smc.vnet.net>

Will Robertson wrote: > Hello, > > I've written a potentially inefficient algorithm to combine multiple > joined polygons into a single one. On large plots I get the warning > "$RecursionLimit::reclim: Recursion depth of 256 exceeded." and a > bunch of errors because of this. > > Now, should I try and re-write my program (the speed of it is not > entirely critical) to avoid recursion or is it "okay" to locally > remove the recursion limit for such code? > > I'll try and post an actual example of my code once I've tidied it up > a little. > > Many thanks, > Will It is safe to increase the value of $RecursionLimit locally: Block[{$RecursionLimit = 1000}, (invoke the function here)] or globally: $RecursionLimit = 1000 . Just make sure that your function actually finishes (and does not go into infinite recursion) before increasing its value further. You can also set $RecursionLimit = Infinity, but it is good to know about this (especially when the kernel quits unexpectedly): (from the doc page) "On most computers, each level of recursion uses a certain amount of stack space. $RecursionLimit allows you to control the amount of stack space that Mathematica can use from within Mathematica. On some computer systems, your whole Mathematica session may crash if you allow it to use more stack space than the computer system allows." -- Szabolcs