[Maxima] Inserting elements into list

Alexey Beshenov al at beshenov.ru
Thu Apr 10 10:15:48 CDT 2008


On Thursday 10 April 2008 05:11, German Mendez wrote:
>  Are threre any way to insert elements in the middle of a list?
>
>  some like this:
>
>           L:[1,2,4,5];
>           insert( L , 3, 3 );
>
> Thanks!

insert (e,l,p) := (
  if p=1 or l=[]
    then cons(e,l)
  else
    cons(first(l),insert(e,rest(l),p-1))
)$

-- 
Alexey Beshenov <al at beshenov.ru>
http://beshenov.ru/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.math.utexas.edu/pipermail/maxima/attachments/20080410/bb4b6db9/attachment.pgp 


More information about the Maxima mailing list