[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: behavior of arrays
Jack Saba <email@example.com> writes:
> But more often than not, I WANT the extra dimension to be lost,
> or at least I want IDL to be willing to ignore it where appropriate.
> Consider this unrealistic example that nevertheless illustrates a
> problem that occurs all too often in IDL:
> IDL> x=findgen(100)
> IDL> ijk=where(x eq 10)
> IDL> for i=ijk,99 do print, i
> % Expression must be a scalar in this context: I.
> % Execution halted at: $MAIN$
> I could have written i=ijk,99, or i=REFORM(ijk),99 to avoid the
> error. But it shouldn't be necessary -- this should be handled
It is handled transparently. If you want a scalar, write ijk.
This works even where ijk is *indeed* a scalar.
This is, BTW, about the only way to check for the result of "where" in a
w = where(x)
if (w lt 0)
David Kastrup Phone: +49-234-700-5570
Email: firstname.lastname@example.org Fax: +49-234-709-4209
Institut für Neuroinformatik, Universitätsstr. 150, 44780 Bochum, Germany