
Calling Sequence


MultiSet( element_spec, ... )
MultiSet['generalized']( element_spec, ... )


Parameters


element_spec



specifies the MultiSet elements and their multiplicities

generalized



literal index which indicates that a generalized MultiSet should be constructed





Description


•

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 twoelement lists, where the second element of each list is a nonnegative 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 nonnegative 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 setoflistsofpairs 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).

•

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 nonMultiSet operand will be converted to a MultiSet before the operation is carried out.

•

Generalized and standard (nongeneralized) 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.



List of MultiSet Object Commands


•

The following is a list of the commands which work with MultiSet objects.



Examples


>

$M\u2254\mathrm{MultiSet}\left(a\=2\,\left[b\,4\right]\,c\right)$

${M}{\u2254}\left\{\left[{a}{\,}{2}\right]{\,}\left[{b}{\,}{4}\right]{\,}\left[{c}{\,}{1}\right]\right\}$
 (1) 
>

$N\u2254\mathrm{MultiSet}\[\mathrm{generalized}\]\left(\left[\left[x\,4\right]\,\left[y\,\frac{3}{2}\right]\,\left[z\,2\right]\right]\right)$

${N}{\u2254}\left\{\left[{x}{\,}{4}\right]{\,}\left[{y}{\,}\frac{{3}}{{2}}\right]{\,}\left[{z}{\,}{}{2}\right]\right\}$
 (2) 
>

$\mathrm{evalb}\left(M\=\mathrm{MultiSet}\left(\mathrm{Entries}\left(M\right)\right)\right)$

>

$\mathrm{Entries}\left(M\right)$

$\left\{\left[{a}{\,}{2}\right]{\,}\left[{b}{\,}{4}\right]{\,}\left[{c}{\,}{1}\right]\right\}$
 (4) 


Compatibility


•

The MultiSet object was introduced in Maple 2016.



