Sababa uses binary digits to represent the values of true and false. The number "0" represents a false evaluation. Where, on the other hand, the number "1" represents a true evaluation.
The built-in boolean operators are as follows:
Boolean Operator | Function |
---|---|
< | less than |
> | greater than |
<= | less than OR equal to |
>= | greater than OR equal to |
== | equal to |
!= | not equal to |
Boolean operator usage, as with every part of the language follows Polish notation, therefore, the operator must precede the integers.
Some examples are as follows:
sababa> < 2 1
=> 0
sababa> >= 2 2
=> 1
sababa> < 4 (+ 3 5)
=> 1
sababa> + 6 (< 8 9)
=> 7
In the first example, 2 < 1 was evaluated as false, and zero was printed out.
In the second example, 2 >= 2 was evaluated to true, since to is greater OR EQUAL TO itself.
In the third example, 3 + 5 were first added to 8, and then 4 < 8 was run, which returned 1 for true.
In the final example, I wanted to illustrate, that the 0 or 1 you get back from a boolean evaluation, may be used in arithmetic. Unlike some languages, where the 0 you get back is in fact a NULL type, as oppose to an actual integer - but that is for another time.