Iterating over the elements of a MultiSet
for e in M do ... end do
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
Note that the traversal order is not specified, but the a's will appear together, as will the b's
Download Help Document