[Maxima] distinct elements in a list
robert.dodier at gmail.com
Sun Jun 17 22:41:19 CDT 2007
On 6/17/07, sen1 at math.msu.edu <sen1 at math.msu.edu> wrote:
> Given a list 'list_1', one way to make a list of the distinct
> elements of 'list_1' is;
> Is there a better (i.e., faster) way ?
Glancing at src/nset.lisp, there doesn't seem to be a single
function to do that, and from what I can tell, the formulation
above should work OK.
I think there should be a function specifically for the purpose
of returning the distinct elements of a list; it could be called "unique".
(defun $unique (x)
(if ($listp x)
`((mlist) ,@(sorted-remove-duplicates (sort (cdr x) '$orderlessp)))
More information about the Maxima