[slang-users] possible returns values for where

John E. Davis davis at space.mit.edu
Fri Dec 23 11:49:21 EST 2005


Joe Miller <lpe540 at yahoo.com> wrote:
>the script does essencially the following
>    index = where (x < y);
>    if ((length (index) == 1) and (index[0] != -1)){
>        ....
>    }
>As far as I know there's no way for the 'where'
>function to return a negative value. But I wanted to
>double check before I took it out.

  The elements of the array returned by `where` will be >= 0.  Note
that the above is also flawed because `where` can return an array with
no elements, and since the `and` operator does not short-circuit, the
execution of index[0] will result in a range-error if index has no
elements.

--John




More information about the slang-users-l mailing list