[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: User selectable lower array bound?
Martin Schultz wrote:
>
> Marc Schellens <m_schellens@hotmail.com> writes:
>
> > Ahem:
> >
> > pro push,list,elem
> > if n_elements(list) eq 0 then list=[elem] else list=[list, elem]
> > end
> >
> > cheers,
> > marc
>
> Won't work if elem is an array ;-(
For rank-1 arrays, shur it will (Can lists, as defined by JD's Perl description be other
than rank-1?) I do it all the time. Except that I would do:
if n_elements(list) eq 0 then list=elem else list=[list, elem]
For 2-D arrays you would have to check for conformability in your own code but that's also
easy to do. 4 or 5-D arrays would be a problem because at some point IDL chucks a nervous
wobbly when you try to do stuff like:
list = [[[[list]]],[[[elem]]]]
or somesuch sort of thing (i.e. too many "[]"'s). I think Craig Markwardt posted something
about this once.
> And if elem is a structure you will soon need something like
> Relax_StructAssign...
Shur, but I thought the whole point of something like Marc's push procedure was to
eliminate all the nasty details from the user (be they 2-d array or structure details),
i.e. it doesn the conformability check or the relaxed structure assignment?
paulv
--
Paul van Delst A little learning is a dangerous thing;
CIMSS @ NOAA/NCEP Drink deep, or taste not the Pierian spring;
Ph: (301)763-8000 x7274 There shallow draughts intoxicate the brain,
Fax:(301)763-8545 And drinking largely sobers us again.
Alexander Pope.