/usr/share/gap/lib/set.gd is in gap-libs 4r7p9-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | #############################################################################
##
#W set.gd GAP library Martin Schönert
##
##
#Y Copyright (C) 1997, Lehrstuhl D für Mathematik, RWTH Aachen, Germany
#Y (C) 1998 School Math and Comp. Sci., University of St Andrews, Scotland
#Y Copyright (C) 2002 The GAP Group
##
## This file contains some functions for proper sets.
##
## <#GAPDoc Label="[1]{set}">
## The following functions, if not explicitly stated differently,
## take two arguments, <A>set</A> and <A>obj</A>,
## where <A>set</A> must be a proper set,
## otherwise an error is signalled;
## If the second argument <A>obj</A> is a list that is not a proper set
## then <Ref Func="Set"/> is silently applied to it first.
## <#/GAPDoc>
##
#############################################################################
##
#F SSortedListList( <list> ) . . . . . . . . . . . . . . . . . set of <list>
##
## <ManSection>
## <Func Name="SSortedListList" Arg='list'/>
##
## <Description>
## <Ref Func="SSortedListList"/> returns a mutable, strictly sorted list
## containing the same elements as the <E>internally represented</E> list
## <A>list</A> (which may have holes).
## <Ref Func="SSortedListList"/> makes a shallow copy, sorts it,
## and removes duplicates.
## <Ref Func="SSortedListList"/> is an internal function.
## </Description>
## </ManSection>
##
DeclareSynonym( "SSortedListList", LIST_SORTED_LIST );
#############################################################################
##
#O IsEqualSet( <list1>, <list2> ) . . . . check if lists are equal as sets
##
## <#GAPDoc Label="IsEqualSet">
## <ManSection>
## <Oper Name="IsEqualSet" Arg='list1, list2'/>
##
## <Description>
## <Index Subkey="for set equality">test</Index>
## tests whether <A>list1</A> and <A>list2</A> are equal
## <E>when viewed as sets</E>, that is if every element of <A>list1</A> is
## an element of <A>list2</A> and vice versa.
## Either argument of <Ref Oper="IsEqualSet"/> may also be a list that is
## not a proper set, in which case <Ref Func="Set"/> is applied to it first.
## <P/>
## If both lists are proper sets then they are of course equal if and only
## if they are also equal as lists.
## Thus <C>IsEqualSet( <A>list1</A>, <A>list2</A> )</C> is equivalent to
## <C>Set( <A>list1</A> ) = Set( <A>list2</A> )</C>
## (see <Ref Func="Set"/>), but the former is more efficient.
## <P/>
## <Example><![CDATA[
## gap> IsEqualSet( [2,3,5,7,11], [11,7,5,3,2] );
## true
## gap> IsEqualSet( [2,3,5,7,11], [2,3,5,7,11,13] );
## false
## ]]></Example>
## </Description>
## </ManSection>
## <#/GAPDoc>
##
DeclareOperation( "IsEqualSet", [ IsList, IsList ] );
#############################################################################
##
#O IsSubsetSet( <list1>, <list2> ) . check if <list2> is a subset of <list1>
##
## <#GAPDoc Label="IsSubsetSet">
## <ManSection>
## <Oper Name="IsSubsetSet" Arg='list1, list2'/>
##
## <Description>
## tests whether every element of <A>list2</A> is contained in <A>list1</A>.
## Either argument of <Ref Oper="IsSubsetSet"/> may also be a list
## that is not a proper set,
## in which case <Ref Func="Set"/> is applied to it first.
## </Description>
## </ManSection>
## <#/GAPDoc>
##
DeclareOperation( "IsSubsetSet", [ IsList, IsList ] );
#############################################################################
##
#O AddSet( <set>, <obj> ) . . . . . . . . . . . . . . . add <obj> to <set>
##
## <#GAPDoc Label="AddSet">
## <ManSection>
## <Oper Name="AddSet" Arg='set, obj'/>
##
## <Description>
## <Index Subkey="an element to a set">add</Index>
## adds the element <A>obj</A> to the proper set <A>set</A>.
## If <A>obj</A> is already contained in <A>set</A> then <A>set</A> is not
## changed.
## Otherwise <A>obj</A> is inserted at the correct position such that
## <A>set</A> is again a proper set afterwards.
## <P/>
## Note that <A>obj</A> must be in the same family as each element of
## <A>set</A>.
## <Example><![CDATA[
## gap> s := [2,3,7,11];;
## gap> AddSet( s, 5 ); s;
## [ 2, 3, 5, 7, 11 ]
## gap> AddSet( s, 13 ); s;
## [ 2, 3, 5, 7, 11, 13 ]
## gap> AddSet( s, 3 ); s;
## [ 2, 3, 5, 7, 11, 13 ]
## ]]></Example>
## </Description>
## </ManSection>
## <#/GAPDoc>
##
DeclareOperation( "AddSet", [ IsList and IsMutable, IsObject ] );
#############################################################################
##
#O RemoveSet( <set>, <obj> ) . . . . . . . . . . . . remove <obj> from <set>
##
## <#GAPDoc Label="RemoveSet">
## <ManSection>
## <Oper Name="RemoveSet" Arg='set, obj'/>
##
## <Description>
## <Index Subkey="an element from a set">remove</Index>
## removes the element <A>obj</A> from the proper set <A>set</A>.
## If <A>obj</A> is not contained in <A>set</A> then <A>set</A> is not
## changed.
## If <A>obj</A> is an element of <A>set</A> it is removed and all the
## following elements in the list are moved one position forward.
## <P/>
## <Example><![CDATA[
## gap> s := [ 2, 3, 4, 5, 6, 7 ];;
## gap> RemoveSet( s, 6 ); s;
## [ 2, 3, 4, 5, 7 ]
## gap> RemoveSet( s, 10 ); s;
## [ 2, 3, 4, 5, 7 ]
## ]]></Example>
## </Description>
## </ManSection>
## <#/GAPDoc>
##
DeclareOperation( "RemoveSet", [ IsList and IsMutable, IsObject ] );
#############################################################################
##
#O UniteSet( <set>, <list> ) . . . . . . . . . . . . unite <set> with <list>
##
## <#GAPDoc Label="UniteSet">
## <ManSection>
## <Oper Name="UniteSet" Arg='set, list'/>
##
## <Description>
## <Index Subkey="of sets">union</Index>
## unites the proper set <A>set</A> with <A>list</A>.
## This is equivalent to adding all elements of <A>list</A> to <A>set</A>
## (see <Ref Func="AddSet"/>).
## <P/>
## <Example><![CDATA[
## gap> set := [ 2, 3, 5, 7, 11 ];;
## gap> UniteSet( set, [ 4, 8, 9 ] ); set;
## [ 2, 3, 4, 5, 7, 8, 9, 11 ]
## gap> UniteSet( set, [ 16, 9, 25, 13, 16 ] ); set;
## [ 2, 3, 4, 5, 7, 8, 9, 11, 13, 16, 25 ]
## ]]></Example>
## </Description>
## </ManSection>
## <#/GAPDoc>
##
DeclareOperation( "UniteSet", [ IsList and IsMutable, IsList ] );
#############################################################################
##
#O IntersectSet( <set>, <list> ) . . . . . . . . intersect <set> with <list>
##
## <#GAPDoc Label="IntersectSet">
## <ManSection>
## <Oper Name="IntersectSet" Arg='set, list'/>
##
## <Description>
## <Index Subkey="of sets">intersection</Index>
## intersects the proper set <A>set</A> with <A>list</A>.
## This is equivalent to removing from <A>set</A> all elements of <A>set</A>
## that are not contained in <A>list</A>.
## <P/>
## <Example><![CDATA[
## 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 ]
## ]]></Example>
## </Description>
## </ManSection>
## <#/GAPDoc>
##
DeclareOperation( "IntersectSet", [ IsList and IsMutable, IsList ] );
#############################################################################
##
#O SubtractSet( <set>, <list> ) . . . . . remove <list> elements from <set>
##
## <#GAPDoc Label="SubtractSet">
## <ManSection>
## <Oper Name="SubtractSet" Arg='set, list'/>
##
## <Description>
## <Index Subkey="a set from another">subtract</Index>
## subtracts <A>list</A> from the proper set <A>set</A>.
## This is equivalent to removing from <A>set</A> all elements of
## <A>list</A>.
## <P/>
## <Example><![CDATA[
## gap> set := [ 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 ];;
## gap> SubtractSet( set, [ 6, 10 ] ); set;
## [ 2, 3, 4, 5, 7, 8, 9, 11 ]
## gap> SubtractSet( set, [ 9, 4, 6, 8 ] ); set;
## [ 2, 3, 5, 7, 11 ]
## ]]></Example>
## </Description>
## </ManSection>
## <#/GAPDoc>
##
DeclareOperation( "SubtractSet", [ IsList and IsMutable, IsList ] );
#############################################################################
##
#E
|