Re: Exiting a Nested operation...
- To: mathgroup at smc.vnet.net
- Subject: [mg127991] Re: Exiting a Nested operation...
- From: Daniel <dosadchy at its.jnj.com>
- Date: Fri, 7 Sep 2012 04:58:50 -0400 (EDT)
- Delivered-to: firstname.lastname@example.org
- Delivered-to: email@example.com
- Delivered-to: firstname.lastname@example.org
- Delivered-to: email@example.com
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.