28.7 IntersectSet

IntersectSet( set1, set2 )

IntersectSet intersects the set set1 with the set set2. This is equivalent to removing all the elements that are not in set2 from set1 (see RemoveSet). set1 must be a set, otherwise an error is signalled. set2 may be a list that is not a proper set, in which case IntersectSet silently applies Set to it first (see Set). IntersectSet returns nothing, it is only called to change set1.

    gap> set := [ 2, 3, 4, 5, 7, 8, 9, 11, 13, 16 ];;
    gap> IntersectSet( set, [ 3, 5, 7, 9, 11, 13, 15, 17 ] );  set;
    [ 3, 5, 7, 9, 11, 13 ]
    gap> IntersectSet( set, [ 9, 4, 6, 8 ] );  set;
    [ 9 ] 

The function IntersectionSet (see Set Functions for Sets) is the nondestructive counterpart to the destructive procedure IntersectSet.

Previous Up Top Next
Index

GAP 3.4.4
April 1997