Next Previous Contents

12. Relational commands

The commands in this section deal with flags. A flag is just a real number. If its value is 0, the flag is false. Any other value means true.

12.1 The == command

This command compares its two arguments and returns 1 if they are equal.

Examples:

> 4 4 ==
[ 1]                         1
> 4 5 ==
[ 2]                         1
[ 1]                         0

12.2 The != and # commands

These commands (they are actually the same command, but with two names) compare their two arguments and return 1 if they are not equal, that is, different.

Examples:

> 4 4 !=
[ 1]                         0
> 4 5 #
[ 2]                         0
[ 1]                         1

12.3 The < command

This command compares its arguments and returns 1 if the one in level two is less than the one in level one.

Examples:

> 4 6 <
[ 1]                         1
> 4 -2 <
[ 2]                         1
[ 1]                         0

12.4 The > command

This command compares its arguments and returns 1 if the one in level two is greater than the one in level one.

Examples:

> 4 6 >
[ 1]                         0
> 4 -2 >
[ 2]                         0
[ 1]                         1

12.5 The <= command

This command compares its arguments and returns 1 if the one in level two is less than or equal to the one in level one.

Examples:

> 4 5 <=
[ 1]                         1
> 4 4 <=
[ 2]                         1
[ 1]                         1
> 4 3 <=
[ 3]                         1
[ 2]                         1
[ 1]                         0

12.6 The >= command

This command compares its arguments and returns 1 if the one in level two is greater than or equal to the one in level one.

Examples:

> 4 5 >=
[ 1]                         0
> 4 4 >=
[ 2]                         0
[ 1]                         1
> 4 3 >=
[ 3]                         0
[ 2]                         1
[ 1]                         1

12.7 The and command

This command performs a logical and between two flags. The result is 1 if both flags are true.

Examples:

> 1 0 and
[ 1]                         0
> 1 1 and
[ 2]                         0
[ 1]                         1

12.8 The or command

This command performs a logical or between two flags. The result is 1 if either flag is true.

Examples:

> 1 0 or
[ 1]                         1
> 0 0 or
[ 2]                         1
[ 1]                         0

12.9 The xor command

This command performs a logical xor between two flags. The result is 1 if only one of the flags is true.

Examples:

> 0 1 xor
[ 1]                         1
> 1 1 xor
[ 2]                         1
[ 1]                         0

12.10 The not command

This command inverts the flag given as argument to it. A true becomes a false, and a false becomes a true.

Examples:

> 1 not
[ 1]                         0
> not
[ 1]                         1


Next Previous Contents