listlib::removeDuplicates
-- removes
duplicate entrieslistlib::removeDuplicates(
list)
removes
all duplicate entries of the list list
.
listlib::removeDuplicates(list)
listlib::removeDuplicates(list, KeepOrder)
list |
- | a MuPAD list |
KeepOrder |
- | listlib::removeDuplicates( list, KeepOrder) returns a list with unique entries
in the order of their occurence in list . |
a list that contains each entry only once
listlib::removeDupSorted
,
DOM_LIST
listlib::removeDuplicates(
list)
removes
all duplicates of each entry of the list list
. The new
list is build up from right to left with the order of the last
occurence of each entry in list
. Cf. Example 1.set
and back into a
list. You will loose the order of the list entries in this case. Cf.
Example 3.listlib::removeDuplicates(
list, KeepOrder)
returns a list of the entries of
list
in the order of their first occurence. The
list is build up from left to right. Cf. Example 2.Per default listlib::removeDuplicates
removes duplicate entries in reverse order:
>> list:= [1, 1, 1, 3, 1, 5, 5, 1, 3, 3, 1, 7]: listlib::removeDuplicates(list)
[5, 3, 1, 7]
With option KeepOrder entries are selected in the order of their occurence:
>> list:= [1, 1, 1, 3, 1, 5, 5, 1, 3, 3, 1, 7]: listlib::removeDuplicates(list, KeepOrder)
[1, 3, 5, 7]
If you don't need the order of list entries any more, you may convert the list into a set and back into a list:
>> list:= [1, 1, 1, 3, 1, 5, 5, 1, 3, 3, 1, 7]: [op({op(list)})]
[7, 5, 3, 1]
listtools::removeDuplicates