overview of MultiSets
List of MultiSet Object Commands
MultiSet( element_spec, ... )
MultiSet['generalized']( element_spec, ... )
specifies the MultiSet elements and their multiplicities
literal index which indicates that a generalized MultiSet should be constructed
A MultiSet is a data structure which stores and manipulates an unordered collection of elements which may be repeated. It is implemented as a Maple object. The procedure exports of a MultiSet are used to create, update, query and otherwise interact with one or more MultiSet objects.
A MultiSet can be constructed from another MultiSet, from a set or list of elements, or from an expression sequence of elements with their multiplicities:
If M is a MultiSet, then MultiSet(M) produces a new MultiSet with the same elements and multiplicities.
If L is a Maple list or set of two-element lists, where the second element of each list is a non-negative integer (normal case) or real number (generalized case), then MultiSet(L) is a MultiSet whose elements are the first elements of each list with multiplicities given by the corresponding second elements of each list.
If L is any other Maple list, then MultiSet(L) is a MultiSet of the same elements, with multiplicities the same as in L.
If S is any other Maple set, then MultiSet(S) is a MultiSet of the same elements, each with multiplicity 1.
Each of the expressions M( a, b=2, c=3 ) and M( a, [b, 2], [c, 3] ) constructs a MultiSet in which the element a has multiplicity 1, b has multiplicity 2 and c has multiplicity 3. Here a, b, and c can be any Maple expressions.
Multiplicities must be non-negative integers, unless the generalized index is provided on the constructor, in which case arbitrary (real) numeric multiplicities are also permitted. An element with multiplicity 0 is removed from its MultiSet.
MultiSets are displayed using a set-of-lists-of-pairs notation, but MultiSets are not sets in the usual Maple sense. The convert command can be used to realize a MultiSet in a variety of different alternate formats.
To test whether an expression is a MultiSet, use type(..., MultiSet).
To iterate over a MultiSet, see MultiSet Iteration.
For commands which operate on more than one MultiSet, for example intersect, at least one operand must be a MultiSet. Other operands can be MultiSets, sets or lists; a non-MultiSet operand will be converted to a MultiSet before the operation is carried out.
Generalized and standard (non-generalized) MultiSets cannot be combined in commands which operate on more than one MultiSet. Note that this means that if a generalized MultiSet appears in an operation, for example, union, with another argument which is not a MultiSet (for example, a list or set), then that other argument will be converted to a generalized MultiSet before proceeding with the operation.
The command IsGeneralized(M) can be used to determine if a MultiSet is generalized or not.
The following is a list of the commands which work with MultiSet objects.
M ≔ MultiSet⁡a=2,b,4,c
N ≔ MultiSetgeneralized⁡x,4,y,32,z,−2
The MultiSet object was introduced in Maple 2016.
For more information on Maple 2016 changes, see Updates in Maple 2016.
Download Help Document