1.3 About First Steps

A simple calculation with GAP is as easy as one can imagine. You type the problem just after the prompt, terminate it with a semicolon and then pass the problem to the program with the return key. For example, to multiply the difference between 9 and 7 by the sum of 5 and 6, that is to calculate (9 - 7) * (5 + 6), you type exactly this last sequence of symbols followed by ; and return.

    gap> (9 - 7) * (5 + 6);
    22
    gap> 

Then GAP echoes the result 22 on the next line and shows with the prompt that it is ready for the next problem.

If you did omit the semicolon at the end of the line but have already typed return, then GAP has read everything you typed, but does not know that the command is complete. The program is waiting for further input and indicates this with a partial prompt . This little problem is solved by simply typing the missing semicolon on the next line of input. Then the result is printed and the normal prompt returns.

    gap> (9 - 7) * (5 + 6)
    > ;
    22
    gap> 

Whenever you see this partial prompt and you cannot decide what GAP is still waiting for, then you have to type semicolons until the normal prompt returns.

In every situation this is the exact meaning of the prompt gap : the program is waiting for a new problem. In the following examples we will omit this prompt on the line after the result. Considering each example as a continuation of its predecessor this prompt occurs in the next example.

In this section you have seen how simple arithmetic problems can be solved by GAP by simply typing them in. You have seen that it doesn't matter whether you complete your input on one line. GAP reads your input line by line and starts evaluating if it has seen the terminating semicolon and return.

It is, however, also possible (and might be advisable for large amounts of input data) to write your input first into a file, and then read this into GAP; see Edit and Read for this.

Also in GAP, there is the possibility to edit the input data, see Line Editing.

Previous Up Top Next
Index

GAP 3.4.4
April 1997