[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: User selectable lower array bound?
> 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
cheers,
marc