Programming with GAP: First session with GAP

Key Points

First session with GAP
  • Remember that GAP is case-sensitive!

  • Do not panic seeing ‘Error, Variable: ‘FuncName’ must have a value’.

  • Care about names of variables and functions.

  • Use command line editing.

  • Use autocompletion instead of typing names of functions and variables in full.

  • Use ? and ?? to view help pages.

  • Set default help format to HTML using SetHelpViewer.

  • Use LogTo function to save all GAP input and output into a text file.

  • If calculation takes too long, press -C to interrupt it.

  • Read ‘A First Session with GAP’ from the GAP Tutorial.

Some more GAP objects
  • GAP has a plethora of variious immediate, positional and component objects.

  • List arithmetic is very flexible and powerful.

  • Objects like lists and records are good to keep structured and related data.

Functions in GAP
  • Command line is good for prototyping; functions are good for repeated calculations.

  • Informative function names and comments will make code more readable to your future self and to others.

  • Beware of undeclared local variables!

Using regression tests
  • It is easy to create a test file by copying and pasting GAP session.

  • Writing a good and comprehensive test suite requires some efforts.

  • Make it right, then make it fast!

Small groups search
  • Organise the code into functions.

  • Create small groups one by one instead of producing a huge list of them.

  • Using SmallGroupsInformation may help to reduce the search space.

  • GAP is not a magic tool: theoretical knowledge may help much more than brute-force approach.

Attributes and Methods
  • Positional objects may accumulate information about themselves during their lifetime.

  • This means that next time the stored information may be retrieved at zero costs.

  • Methods are bunches of functions; the method selection will choose the most efficient method based on the type of all arguments.

  • ‘No-method-found’ is a special kind of error with useful debugging tools helping to understand it.

First session with GAP

Some more GAP objects

Functions in GAP

Using regression tests

Attributes and Methods


Operation (normally, one-argument), the result of which is stored in its argument and cannot be changed any more.
Data structure whose elements are indexed by their position in the list.
Function that will be called for an operation for arguments of the specified type.
GAP function for which several methods may be available (the particular method that will be used depends on the type of the arguments).
Boolean-valued attribute
Data structure which is a collection of components, each having a unique name, which is an identifier that distinguishes this component, and a value, which is an object of arbitrary type.
Regression testing
Testing based on rerunning previously completed tests to check that new changes do not impact their correctness or worsen their performance.