Insert - Maple Help

MultiSet/Insert

insert an element into a MultiSet

 Calling Sequence Insert( M, x, n ) Insert( M, x=n ) Insert( M, [x, n] ) Insert( M, x )

Parameters

 M - MultiSet; a MultiSet x - anything, an expression n - nonnegint, number of copies of x to insert into M

Description

 • Each of the first three calling sequences, Insert( M, x, n ), Insert( M, x=n ), and Insert( M, [x, n] ), increments the multiplicity of x in the MultiSet M by n.
 • The fourth calling sequence, Insert( M, x ) is equivalent to Insert( M, x, 1 ).
 • The new multiplicity of x in M is returned.
 • To set the multiplicity of an element to a specific value, use the selection operator. For example, to set the multiplicity of x to 3, use M[x] := 3.

Examples

 > $M≔\mathrm{MultiSet}\left(a=2,b=5\right)$
 ${M}{≔}\left\{\left[{a}{,}{2}\right]{,}\left[{b}{,}{5}\right]\right\}$ (1)
 > $\mathrm{Insert}\left(M,b,3\right)$
 ${8}$ (2)
 > $\mathrm{Insert}\left(M,c\right)$
 ${1}$ (3)
 > $M$
 $\left\{\left[{a}{,}{2}\right]{,}\left[{b}{,}{8}\right]{,}\left[{c}{,}{1}\right]\right\}$ (4)

Compatibility

 • The MultiSet/Insert command was introduced in Maple 2016.