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

Re: Generally accessing the rest of the elements in an array

Paul van Delst wrote:
> William Thompson wrote:
> > "tbowers" <tbowers@nrlssc.navy.mil> writes:
> > >How do I access the 2nd + dimensions of an array generally, without knowing
> > >the
> > >number of higher dims this array has.
> > You should be able to do something like the following:
> >     b = a[0,*,*,*,*,*,*,*]^2 + a[1,*,*,*,*,*,*,*]^2 + a[2,*,*,*,*,*,*,*]^2
> Ugh.
> I think Mr/Dr Bowers should think about a new data structure that can deal with the
> flexibility he requires. An IDL structure perhaps?

What makes IDL arrays different from arrays in some other languages is
the fact that they *have* this flexibility. Whether one requires it or
not. The dimensions of arrays can change anytime, and even IDL itself
takes the freedom to remove dimensions if they happen to be of size 1.
Now in *my* personal viewpoint, the challenge is to write IDL code which
is able to handle input of any type and dimension for which a sensible
reaction can be defined. So if I were to write a function which
calculates the square of the Nth column, I would try to write it for any
dimensions and for any type (except for strings maybe). 


PS:  It's just that I wrote a lot of things originally for byte time
traces. Later on I of course ended up wanting to apply them to complex
arrays of 2 or 3 dimensions. In most cases I was amazed at how easy it
*would* have been to write them fully generic in the first place.