Expressions
By:Gap
An expression is a construct that evaluates to a value. Syntactic constructs that are executed to
produce a side effect and return no value are called statements(see Statements). Expressions appear
as right hand sides of assignments (see Assignments), as actual arguments in function calls
(see Function Calls), and in statements.
Note that an expression is not the same as a value. For example 1 + 11 is an expression, whose
value is the integer 12. The external representation of this integer is the character sequence 12, i.e.,
this sequence is output if the integer is printed. This sequence is another expression whose value is
the integer 12. The process of finding the value of an expression is done by the interpreter and is
called the evaluation of the expression.
Variables, function calls, and integer, permutation, string, function, list, and record literals
(see Variables, Function Calls, Integers, Permutations, Strings and
Characters, Functions, Lists, Records), are the simplest cases of expressions.
Expressions, for example the simple expressions mentioned above, can be combined with the
operators to form more complex expressions. Of course those expressions can then be combined
further with the operators to form even more complex expressions. The operators fall into three
classes. The comparisons are =,<>, <, <=, >, >=, and in (see Comparisons and Membership Test for
Collections). The arithmetic operators are +, -, *, /, mod, and ^ (see Arithmetic Operators).
The logical operators are not, and, and or (see Operations for Booleans).
The following example shows a very simple expression with value 4 and a more complex
expression.
gap> 2 * 2;
4
gap> 2 * 2 + 9 = Fibonacci(7) and Fibonacci(13) in Primes;
true
Reference : http://www.gap-system.org/Manuals//doc/htm/ref/CHAP004.htm#SECT007
Date:17-9-2008