On Thu, Apr 10, 2008 at 11:55 AM, Oliver Kullmann
> The performance regarding speed of Maxima w.r.t. list operations is a complete disaster...
> It seems to me due to the lack of a suitable set of operations, for example for in-place modifications of lists.
Maxima intentionally does not provide functions for in-place
modification of lists because lists are considered as *values*, not as
*objects*, just like numbers.(*) This keeps the semantics simple and
avoids complications like aliasing (modifying one list has the
side-effect of modifying a different one) and circular lists (which
Maxima cannot print), which are especially problematic for
mathematical users (as opposed to programmers).
If you really want to build modifying operators on Maxima lists, it
suffices to have one new primitive:
(defun $set_rest (l new)
(cond ((or (atom l)
(not (eq (caar l) 'mlist))
(not (cdr l)))
(merror "Can only replace rest of non-null lists: ~:M" l))
((or (atom new) (not (eq (caar new) 'mlist)))
(merror "Can only replace rest with a list: ~:M" new))
(t (rplacd (cdr l) (cdr new))
l)))
Have fun.
-s
(*) This is not quite true. It is possible to modify the value of a
particular position in a list, treating it as an array, e.g.
ll:[a,b,c]$ ll[2]:9$ ll => [a,9,c].