[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: N_ELEMENTS and WHERE: Scalar or Array ?
- Subject: Re: N_ELEMENTS and WHERE: Scalar or Array ?
- From: steinhh(at)ulrik.uio.no (Stein Vidar Hagfors Haugan)
- Date: 1 Feb 1999 10:34:07 GMT
- In-reply-to: email@example.com's message of 1 Feb 1999 09:51:48 GMT
- Newsgroups: comp.lang.idl-pvwave
- Organization: University of Oslo, Norway
- References: <firstname.lastname@example.org> <email@example.com>
- Xref: news.doit.wisc.edu comp.lang.idl-pvwave:13504
In article <firstname.lastname@example.org> email@example.com writes:
> But since this has come up, & its one of my pet peeves: why cannot where
> return a null array to indicate no-elements-match. And then array[null] would
> match to nothing. This would allow one to say
> instead of the ugly
> if (count gt 0) then array[i]='stoat'
> I use Perl a lot, and the contrast is very striking there: perl handles null
> values quite happily and it simplifies a lot of things.
I agree, it would be a nice feature... However, I have problems
seeing how to implement this, without altering e.g. the way IDL
allows you to index arrays with an array that is out of
bounds.. (try help,(findgen(10))(findgen(20)-5))
Maybe using (float/double) NaN values? Hmm. That could work!
array[NaN] = 5 ; Would be allowed, but does nothing
array[ [NaN,0] ] = 5 ; Assigns 5 to element 0 only.
data = array[NaN] ; data is set to NaN !
data = array[ [NaN,0] ] ; Data is set to array
The only problem I can see is that the indices will sometimes
have to be converted to floats/doubles in order to store the NaN
values, thus some overhead will occur...
> While I'm here: would RSI please put a decent regexp package into IDL?
Take a look at http://www.uio.no/~steinhh/IDL/additions.html for an
example of how to add it using dynamically loadable modules.
It requires a Unix flavor with regex.h, or alternatively the POSIX
compliant inteface for the GNU regular expression library (not
tested, though) - see
http://sunland.gsfc.nasa.gov/info/regex/Top.html, especially the
section "Programming with Regex".