Programming with GAP: First session with GAP

Key Points

First session with GAP
  • Use command line editing.

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

  • Use ? and ?? to view help pages.

  • Premature optimization is the root of all evil!

  • Premature optimization is the root of all evil!!

  • Functional programming can make code not only concise but also unreadable if nested too much.

  • Permutations are multiplied from left to right.

Some more GAP objects
  • GAP has a plethora of various 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!

  • The break loop can be extremely helpful for debugging.

  • You can interrupt computations by hitting Ctrl + C.

Using regression tests
  • It is easy to create a test file by copying and pasting GAP session or use the LogTo-command.

  • Writing a good test suite is an art in itself.

  • 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.

  • Determining the isomorphism type of a group.

  • 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 is done by using Attributes.

  • 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.

First session with GAP

Some more GAP objects

Functions in GAP

Using regression tests

Attributes and Methods

Glossary

Attribute
Operation (normally, one-argument), the result of which is stored in its argument and cannot be changed any more.
List
Data structure whose elements are indexed by their position in the list.
Method
Function that will be called for an operation for arguments of the specified type.
Operation
GAP function for which several methods may be available (the particular method that will be used depends on the type of the arguments).
Property
Boolean-valued attribute
Record
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.