Re: User selectable lower array bound? [message #26142 is a reply to message #25981] |
Wed, 08 August 2001 12:26   |
John-David T. Smith
Messages: 384 Registered: January 2000
|
Senior Member |
|
|
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
|
|
|