RESERVED WORDS / KEYWORDS

 

and      The Boolean operator Ù. This is used when writing Boolean statements such as (8 in S) and (5 notin S)

            Set formers often need this sort of condition.

div       A function that produces the quotient when one number is divided by another. For example, -12 div 5  = -3.

do        This is part of the standard loop pattern. See for.

else, elseif     

These terms may be used in conditional statements; see if. They are used to tell the computer what to do if the condition is false. For example, here is a line of code that might appear in a function.

                        if even(x) then return x/2; else return 3*x+1; end;

end      The end of a control statement. The code end must appear at the end of each if statement, at the end of each func, and at the end of each loop. (See for or while.)

exists  The existential quantifier. It examines a set or a tuple to see if there is at least one element with a certain property.
            exists x in {1..99} | x**2 > 5*x;

false    One of the two Boolean constants.

for       The beginning of the most common type of loop. Here is an example.

                        for x in {1..25} do

                                    if x mod 6 = 0 then print x; end;

                        end;

forall   The universal quantifier. It examines a set or a tuple to see if every element has a certain property.

                        forall t in [6,9 .. 99] | not is_prime(t);

func     A command used when creating a function. The general pattern is:

                        Name of the function := func( List of input variables );

                                    statements saying what to do

                                    return The output value

                                    end;

            Here is a typical example:

                        D := func(x,y);

                                    if x > y then return x - y;

                                    else return y - x;

                                    end;

                        end;

 

if          This is used to let the computer choose between options. It often appears in a loop or in a function. The basic pattern is

                        if some Boolean condition is true then perform some action

Fancier statements may use the if … else … then command. See for for an example of an if statement used in a loop.

iff         The biconditional; this is short for "if and only if". When used between two propositions, it means that the propositions are equivalent, that each implies the other. For example,

                        s and t are relatively prime iff there is a linear combination of s and t equal to 1.

            An ISETL example is: (p and not q) iff not(p impl q);

impl     The Boolean operator "implies". This is used when writing expressions such as (p and q) impl false;

in         This means "is an element of". It is used to checking whether a particular element belongs to a certain set or tuple. It can be part of a conditional statement or part of a loop. For example, if z in {5,10..100} then print z;

            Also see for.

inter    The set operator Ç for the intersection of two sets. The command {2..19} inter {11..25}; will give a result equal to {11..19};

mod     A function that calculates the remainder when one integer is divided by another integer. For example, -27 mod 5; will produce the answer 3. A remainder is always positive or 0, so a mod command will always give a nonnegative answer.

not       The Boolean negation. The command not true; gives false; and, of course, not false; gives true;

notin    This means the same as not in. So x notin S; means the same as not (x in S);

OM     This means that the value is undefined. It could happen when one of the variables has not yet been assigned a value, or it could happen when the arithmetic is illegal (dividing by 0 or taking a square root of a negative number). When it appears after a function, it usually means that the function is missing its return statement. (Only one person knows what OM really stands for, and he isn’t telling!)

or         The Boolean operator Ú. This is used when writing Boolean statements such as (8 in S) or (5 notin S)

            Set formers often need this sort of condition.

print    This tells the computer to print the specified values, one value per line. Usually, it should NOT be used in a function. Instead, a function should use a return command. Compare print to write and to writeln.

return  A command that tells the computer what the output of a function should be. Every function must have at least one return statement in it.

subset Used to check whether one set is included in another. For example, {3,6,8} subset {1..9}  will give true.

then     Part of a conditional statement. See if.

true     One of the two Boolean constants.

union   The set operator È  for the union of two sets. The command

{2..19} union {11..25}; will give a result equal to {2..25};

while    The beginning of a certain type of loop. Here is an example:
                        x := 1;
                        while x < 20 do

                                    x := 2*x; print x;

                        end;

            Be careful with while loops; it is very easy to create an infinite loop accidentally.

write    This tells the computer to print the specified values, with all values in a single line.

writeln This tells the computer to print the specified values, with each set of values on a single line.

            For example, the various printing commands cause this loop to do different things.

                        for n in [1,2,3] do

                                    print n, sqrt(n);

                        end;

            This will produce six numbers on six separate lines. Using write instead of print will produce six values, all on the same line. The best choice may be to use writeln, which will put two values on each line, like this:

1          1.00000

2          1.41421

3          1.73205