next up previous contents
Next: More complicated sets Up: Common data structures Previous: Adding numbers in a   Contents

Membership

It is also pretty easy to check whether or not something is an element of a list:

> 3 in List2;
true
> 11 in List2;
true
To find out how many times 11 occurs in List2 is a little trickier. It must first be converted to a ``MultiSet'' which has the Multiplicity command:

> MultList21:=SequenceToMultiset(List2);
> Type(MultList21);   
SetMulti
> MultList2:=SequenceToMultiset(List2);  
> Type(MultList2); 
SetMulti
> Multiplicity(MultList2,11);            
4



David Joyner 2001-08-22