Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #11648 > unrolled thread
| Started by | Daniel <dosadchy@its.jnj.com> |
|---|---|
| First post | 2012-09-07 08:58 +0000 |
| Last post | 2012-09-07 08:58 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.soft-sys.math.mathematica
Re: Exiting a Nested operation... Daniel <dosadchy@its.jnj.com> - 2012-09-07 08:58 +0000
| From | Daniel <dosadchy@its.jnj.com> |
|---|---|
| Date | 2012-09-07 08:58 +0000 |
| Subject | Re: Exiting a Nested operation... |
| Message-ID | <k2ccuo$f37$1@smc.vnet.net> |
To exit Nest when some condition is met you can Throw an exception, like this: result=NestWhile[ (your code ... .. If[finalConditionIsMet, Throw[someResult]]; .. .. you code end), initial, True&]//Catch; This NextWhile is supposed to run indefinitely (because of the 'True&' as test function), but will exit when 'finalConditionIsMet' is True. For debug you should probably use something like this: result=Nest[ (your code ... .. If[finalConditionIsMet, Throw[someResult]]; .. .. you code end), initial, 50]//Catch; so the NestWhile will not run indefinitely if you have a bug.
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web