![]() |
![]() |
![]() |
![]() |
(Operators..) | Contents | Index | (..Operators..) |
SCARLET provides all the common relational operators on integer expressions
IntExpression in just the form we are used to in daily life.
In detail we are talking about
RelOp: | ||
== | equal to | |
< | less than | |
> | greater than | |
!= | not equal to | |
>= | greater than or equal to | |
<= | less than or equal to |
They compare two operands at a time and return a boolean value corresponding to the resulting logical value.
But relational operators may also be applied to string expressions (short: strings) StringExpression. In this case, the normal comparison for numbers is replaced by the lexical one, that means, two strings are compared character by character, starting at the left and obeying the following rules:
If the exceptional features of the internal order of the ASCII code are not
taken in account, the lexical comparison may sometimes lead to slightly
surprising results:
"bigger" > "big"
TRUE
"mouse" > "MAMMOTHE"
TRUE
"99" > "One"
FALSE
Parts of the ASCII code | |||||||
21 | § | 45 | - | 65 | A | 124 | | |
33 | ! | 46 | . | .. | .. | 125 | } |
34 | " | 47 | / | 90 | Z | 126 | ~ |
35 | # | 48 | 0 | 91 | [ | 129 | ü |
36 | $ | .. | .. | 92 | \ | 132 | ä |
37 | % | 57 | 9 | 93 | ] | 142 | Ä |
38 | & | 58 | : | 94 | ^ | 148 | ö |
39 | ' | 59 | ; | 95 | _ | 153 | Ö |
40 | ( | 60 | < | 96 | ` | 154 | Ü |
41 | ) | 61 | = | 97 | a | 248 | ° |
42 | * | 62 | > | .. | .. | 255 | |
43 | + | 63 | ? | 122 | z | ||
44 | , | 64 | @ | 123 | { |
Because cell expressions CellExpression
consist of one or more registers with the same priority, it does not normally make
sense to ask whether one cell expression is greater (or less) than the other;
but some of the relational operators can successfully be applied to them, too,
namely == (equal) and != (not equal). Here a comparison can be
done by comparing all corresponding registers with each other. Hence
two cell expressions are equal, if the contents of each corresponding
register pair are equal; otherwise they are not equal.
Doing this, we take for granted that both cell expressions have the same
register structure, otherwise they would not be comparable.
(In fact this cannot happen, since the structure is uniformly fixed
for all cell expressions within one program.)
If it is the issue, whether two register contents are equal while one of them
is VOID,
the result will always be TRUE;
(in case of "unequal" it will
be FALSE.) Indeed VOID enables partial comparisons of cell expressions.
{"s", 25, VOID} == {"s", 25, "a"}
TRUE
{"s", 25, VOID} != {"s", 25, "a"}
FALSE
![]() |
![]() |
![]() |
![]() |
(Operators..) | Contents | Index | (..Operators..) |