Newbie question: Howto remove only first element from a list
Subject: Newbie question: Howto remove only first element from a list
From: Raymond Toy (RT/EUS)
Date: Fri, 25 Apr 2008 10:31:34 -0400
Alexey Beshenov wrote:
> On Friday 25 April 2008 18:18, Raymond Toy (RT/EUS) wrote:
>> andre maute wrote:
>>> What is the command to remove only the first element from a list?
>>>
>>> (%i2) a : [1,2,3,4,1];
>>> (%o2) [1,2,3,4,1]
>>> (%i3) delete(1,a);
>>> (%o3) [2,3,4]
>> rest(a) -> [2,3,4,1]
>>
>> Hmm. I see there's a bug in the documentation for rest. It refers to
>> <n>, but it's not one of the parameters to rest.
>
> rest(expr,n) removes first (n>0) or last (n<0) elements; rest(expr) is
> equivalent to rest(expr,1)
Yes, I figure that from reading the documentation. But look at what it
says:
(%i3) ? rest
-- Function: rest (<expr>)
Returns <expr> with its first <n> elements removed if <n> is
positive and its last `- <n>' elements removed if <n> is negative.
If <n> is 1 it may be omitted. <expr> may be a list, matrix, or
other expression.
I think it would be better to say something like
-- Function: rest (<expr>[, <n>])
to make it clear that there's an optional argument allowed.
Ray