MultiSet Selection - Maple Help

Home : Support : Online Help : Programming : Data Types : MultiSet : MultiSet Selection

MultiSet Selection

get or set the multiplicity of an element of a MultiSet

 Calling Sequence M[x] M[x] := n;

Parameters

 M - MultiSet; a MultiSet x - anything, an expression n - numeric, the new multiplicity of x in M

Description

 • M[x] returns the multiplicity of the member x of the MultiSet M.
 • M[x] := n sets the multiplicity of x in M to n.  Note that this is different from Insert( M, x=n ), which increases the multiplicity of x in M by n.
 • Note M[x] := 0 is equivalent to Remove( M, x ).
 • If M is a generalized MultiSet, n may be any real number.  Otherwise, it must be a non-negative integer.

Examples

 > $M≔\mathrm{MultiSet}\left(a=2,b=5\right)$
 ${M}{≔}\left\{\left[{a}{,}{2}\right]{,}\left[{b}{,}{5}\right]\right\}$ (1)
 > $M\left[a\right]$
 ${2}$ (2)
 > $M\left[b\right]≔7$
 ${{M}}_{{b}}{≔}{7}$ (3)
 > $M\left[a\right]≔0$
 ${{M}}_{{a}}{≔}{0}$ (4)
 > $M\left[c\right]≔4$
 ${{M}}_{{c}}{≔}{4}$ (5)
 > $M$
 $\left\{\left[{b}{,}{7}\right]{,}\left[{c}{,}{4}\right]\right\}$ (6)
 > $N≔\mathrm{MultiSet}\left[\mathrm{generalized}\right]\left(\right)$
 ${N}{≔}{\varnothing }$ (7)
 > $N\left[w\right]≔3.14159$
 ${{N}}_{{w}}{≔}{3.14159}$ (8)
 > $N$
 $\left\{\left[{w}{,}{3.14159}\right]\right\}$ (9)