On this occasion:
The performance regarding speed of Maxima
w.r.t. list operations is a complete disaster
(alright, doing it by hand still takes longer,
but not that much ;-)). Not to speak about
sets.
It seems to me due to the lack of a suitable set of
operations, for example for in-place modifications of
lists. The code below does not what likely was
originally intended, namely to modify L, but
creates a copy, and for doing so furthermore it
apparently needs to run through the list.
Wouldn't it make much sense to provide a sensible
set of operations for lists and sets, which provide
*efficient* in-place modifications?
Oliver
On Thu, Apr 10, 2008 at 07:15:48PM +0400, Alexey Beshenov wrote:
> 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/