OM# Documentation

Logical Operators: and/or

and and or are logical operators generally used to test whether all or any of a given number of conditions are met.
They are typically used as tests for conditional / if statements.

The boxes can be added any number of optional inputs, which be evaluated left-to-right until a decision can be made:

Contrary to most boxes in OM# (and functions in Lisp), not all inputs are always evaluated.
The order can change results significantly, and can used to control evaluation flow in visual programs.

The following example tests if the input 1) is a number, 2) is greater than a given value, and 3) is even. Each evaluated branch prints its value. We are sure that if the input is not a number, the other tests will not even be made (they would lead to type errors).

    

Flow control

The following example with or triggers an error if the first branch is NIL. Otherwise, the error branch is not evaluated.

Combining logical operators

Logical operators can be combined into more advanced logical expressions.
The following example tests if the input is either s string or a number that is greater than a given value and even:


See also: Conditional: if