#### Gap Primer

• Assignment
• variable assignment s:=2 gives result
• evaluate s gives result
• a structure date:= rec(year:= 1992, month:= "Jan", day:= 13); returns Result
• day does not have a value, but date.day gives Result
• Modify a list entry. Note the use of ;; to prevent these values from being part of the result. Otherwise Gap will not give an indication between results. Here we see that jim and bil will point to the same object, so that modifying one modifies the other. bil:=[1,2,3,4];;jim:=bil;; jim[1]:=8;; bil gives Result
• Lists
• a regular representation l:=[1,2,5] yields Result
• a compact representation Length([2..500]) gives Result
• search a list Position([1,2,5,7],5) returns Result
• combinding lists Append([1,2,3], [31, 37]) gives Result
• sublists containing certain elements lll:=[true,"bill","jane",7];;lll{[2,4]} yields Result
• make unique Set([3,2,4,2,5]) produces Result
• Vectors and Matrices
• a vector is a list whose elements are from the same field: IsVector([1,2,"bil"]) returns Result
• a matrix is a list of vectors m:=[ [ 1, 2, 3, 4 ], [ 5, 6, 7, 8 ], [ 9, 10, 11, 12 ] ] returns Result
• matrix multiply[1, 0, 0] * m; evaluates to Result
• a mismatch in multiplication m * [1, 0, 0]; produces Result
• m * [1, 0, 0, 0]; returns Result
• submatrices sm := m{ [ 1, 2 ] }{ [ 3, 4 ] } evaluates to Result
• m[2][1] produces Result
• dot product v:=[1,2,3];;v * v evaluates to Result
• apply square function to elements List([1..10],x-> x^2) produces Result
• select elements Filtered([1..20],x-> (x mod 5) = 0) produces Result
• Iteration
• A simple loop. The vector is represented in compact notation numbers:= [2..10]; for v in numbers do Print(v);Print(","); od; produces Result
• sum a vector Sum([1,2,3]) returns Result
• product of 1*3*5*..500 Product([1,2..500]) evaluates to Result
• primes:= [];; numbers:= [2..1000];; for p in numbers do Add(primes, p); for n in numbers do if n mod p = 0 then Unbind(numbers[n-1]); fi; od; od;; primes gives Result
• i:=0 ;;while (i < 10 ) do Print(i,"\n"); i:=i+1; od; evaluates to Result
• Functions
• defining a function
` function(<arguments>) <statements> end  `

cube:=function(x) return x^3; end;; cube(5) returns Result
• anonymous functions List([1..3],x->x^3) gives Result
• local variables should be declared, or unexpected side effects may occur such as inadvertent changing of bil in the following. bil:=3;; jim:=function(x) bil:=x; end;; jim(4);;bil gives Result
• local variables are declared, so value of bil is protected bil:=3;; jim:=function(x) local bil; bil:=x; end;; jim(4);;bil returns Result

### Groups

• The symmetric group on 8 elments can be generated by two permutations s8:= Group( (1,2), (1,2,3,4,5,6,7,8) ); evaluates to Result
• Is SymmetricGroup( 8 ) = Group( (1,2), (1,2,3,4,5,6,7,8) ) ? Yields Result
• Compute the sylow subgroups factors:=Set(Factors( Size( s8 )));; for p in factors do SylowSubgroup( s8, p ); od;; s8.sylowSubgroups; returns Result
• their sizes for p in factors do Print(p,"-sylow has size ",Size(s8. sylowSubgroups[p]), " whose normalizer has size ", Size(Normalizer(s8.sylowSubgroups[p],s8)),"\n");od gives Result