Previous Page Next Page Contents

listlib::removeDuplicates -- removes duplicate entries

Introduction

listlib::removeDuplicates(list) removes all duplicate entries of the list list.

Call(s)

listlib::removeDuplicates(list)
listlib::removeDuplicates(list, KeepOrder)

Parameters

list - a MuPAD list

Options

KeepOrder - listlib::removeDuplicates(list, KeepOrder) returns a list with unique entries in the order of their occurence in list.

Returns

a list that contains each entry only once

Related Functions

listlib::removeDupSorted, DOM_LIST

Details

Option: KeepOrder

Example 1

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]

Example 2

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]

Example 3

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]

Changes




Do you have questions or comments?


Copyright © SciFace Software GmbH & Co. KG 2000