MathGroup Archive 2000

[Date Index] [Thread Index] [Author Index]

Search the Archive

How to Break[] out of nested loops?


In a loop like

Do[
x=LengthyComputation[m];
    Do[
       If[condition[x,n], Break[]],
    {n, nmax}],
{m, mmax}]

the Break[] exits the inner loop. Is there a way of exiting out of the outer
loop? I do not want to write like

Do[
x=LengthyComputation[m];
If[condition[x,n], Break[]],
{m, mmax},{n, nmax}]

because then LengthyComputation[m] is calculated nmax times for each value
of m isnstead of just once.

Thanks in advance.

-- 
Julian Aguirre
Universidad del Pais Vasco



  • Prev by Date: Re: Cell Group
  • Next by Date: Partial Differential Equations
  • Previous by thread: Re:& graphs and buttons
  • Next by thread: Re: How to Break[] out of nested loops?