How to assign partial list



I think that Stavros' answer is simpler, and you get
some error checking (like "REST FELL OFF END"), but as
far as the design goes, I would prefer to take an existing
design, so far as it works, and use it.  Thus the first
thing that came to my mind was not 'let's make up additional
stuff for the Maxima command set.'   but  'what does common
lisp have that we could just import.  In fact we could
name my function f  of the previous message, to be SUBSEQ.
Then the documentation could be "same as Common Lisp SUBSEQ"

There are piles of other functions in that design, including
finding the position of items in the list, removing duplicates,
etc.

If the Lisp functionality is not quite the perfect thing, what to
do? (a) implement it anyway because it is a standard?  or (b)
do something different? 


RJF


Stavros Macrakis wrote:

>>  I have a list, created by a cf(x)-function-call.
>>  I want to use only the first n-entries of the list.
>>    
>>
>
>rest(list,n) removes the first n elements of a list and
>rest(list,-n) removes the last n entries in the list.
>
>So you could define:
>
>  firstn(l,n):=rest(l,n-length(l))$
>
>or use the makelist function:
>
>  makelist(a[i],i,1,n)
>
>----------------
>
>Now switching to a design discussion....
>
>There are several directions this could go.
>
>In terms of the existing list manipulation functions, it would make
>sense to define First and Last as having an optional second argument:
>First(l,n) (n>=0) would be the first n elements, and First(l,n) (n<=0)
>would be the last n elements.  Last(l,n)==First(l,-n).  This would be
>trivial to add if people think it's a good idea.
>
>Adding array slices would be another direction to extend things.  In
>that case, you'd want not just x: a[i..j], but also a[1..i]:
>b[j..j+i-1].  Similarly a[i..j,m..n] for arrays.  This is not rocket
>science, just a little careful design and then "a small matter of
>programming".
>
>_______________________________________________
>Maxima mailing list
>Maxima@www.math.utexas.edu
>http://www.math.utexas.edu/mailman/listinfo/maxima
>  
>