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

Re: User selectable lower array bound?



Marc Schellens wrote:
> 
> > Think Perl.  For example, to add an element or elements to the end of a
> > possibly non-existent list, you say:
> >
> > push @list, $elem;
> >
> > To pull one element off the end:
> >
> > pop @list;
> >
> > To pull one off the front:
> >
> > shift @list;
> >
> > To push one onto the front:
> >
> > unshift @list, $elem;
> >
> > With such a collection we could rid ourselves of all those silly
> > statements like:
> >
> > if n_elements(list) eq 0 then list=[elem] else list=[list, elem]
> 
> Ahem:
> 
> pro push,list,elem
> if n_elements(list) eq 0 then list=[elem] else list=[list, elem]
> end

I had one just like this in my collection, but I just didn't feel right
spawning a function call and path search just to add an element to a
list.  A built-in method would be much preferrable.  

JD