MultiSet Iteration
Iterating over the elements of a MultiSet
Calling Sequence
Parameters
Description
Examples
for e in M do ... end do
M
-
MultiSet; a (non-generalized) MultiSet
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).
M≔MultiSet⁡a,b,c,b,a
M≔a,2,b,2,c,1
Note that the traversal order is not specified, but the a's will appear together, as will the b's
forxinMdoprint⁡xenddo
a
b
c
See Also
do
MultiSet
Download Help Document