MultiSet Iteration - Maple Programming Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Programming : Data Types : MultiSet : MultiSet/Iteration

MultiSet Iteration

Iterating over the elements of a MultiSet

 

Calling Sequence

Parameters

Description

Examples

Calling Sequence

for e in M do ... end do

Parameters

M

-

MultiSet; a (non-generalized) MultiSet

Description

• 

To iterate over the elements of a MultiSet, M, use the for x in M do ... end do construct.  Note that this will loop over all the elements of the MultiSet, repeated according to multiplicity.  Note also that the order in which the elements of the MultiSet are visited is not predetermined, although identical elements will be visited consecutively.

• 

This iteration functionality is only available for standard (non-generalized) MultiSets (where the multiplicities can only be positive integers).

Examples

MMultiSeta,b,c,b,a

Ma,2,b,2,c,1

(1)

Note that the traversal order is not specified, but the a's will appear together, as will the b's

forxinMdoprintxenddo

a

a

b

b

c

(2)

See Also

do

MultiSet