Logical Connectives

Sometimes we have to test complicated logical conditions. Complex conditions can often be expressed in terms of more elementary conditions by means of the logical connectives "AND", "OR", and "NOT". Although Refal Plus does not provide logical connectives explicitly, they can be easily represented by other constructs.

Logical "AND"

Suppose we have two conditions and must determine whether both of them are satisfied.

If both conditions are represented by paths Q' and Q'', the compound condition can be tested by evaluating the path
    \{ Q';}, Q''

If the first condition is represented by a source S, and the second by a path Q, the compound condition can be tested by evaluating the path S, Q.

And, finally, if both conditions are represented by result expressions Re' and Re'', the compound condition can be tested by evaluating the result expression Re' Re".

Logical "OR"

Suppose we have two conditions and must determine whether one (or both) of them are satisfied.

If both conditions are represented by paths Q' and Q'', the compound condition can be tested by evaluating the path
    \{ Q'; Q''; }

Logical "NOT"

Suppose we have a condition represented by a path Q, and must determine whether the condition is not satisfied. This can be done by evaluating the path
    # \{Q;}

which is an abbreviation to the path # \{Q;}, .

In cases where the condition is represented by a source S, the negated condition can be tested by evaluating the path
    # S

which is an abbreviation to the path # S , .

In both cases we take the opportunity of omitting the rests consisting of a single comma.