help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

evaluation of 'or' statements in conditional


From: E. Joshua Rigler
Subject: evaluation of 'or' statements in conditional
Date: Mon, 19 May 2008 14:19:31 -0600

I have a non-functional 'do until' loop that, when simplified, looks like this:

   do
      do_stuff();
      i = increment_array_index(i);
   until i==0 || i==(max_i+1) || array(i) == some_value

The idea is to check if the bounds of the array have been exceeded,
then check to see if the array element meets a pre-defined condition
that breaks the loop.  I guess I expected the condition to return true
as soon as the first item returned true, but it looks like Octave
actually evaluates every single expression, which results in an
attempt to address the array with an out of bounds index.

My question is, is there a preferred way to do this that does not
involve placing a conditional break inside the loop when the array
bounds are exceeded?

-EJR


reply via email to

[Prev in Thread] Current Thread [Next in Thread]