Skip to content

or

Syntax

or(boolean_expression_1, boolean_expression_2)

Parameters

boolean_expression_1 and boolean_expression_2 :
Expressions that are evaluated as truthy (non-zero) or falsey (zero).

Returns

Returns 1 (true) if either expression parameter is truthy (non-zero). Returns 0 (false) otherwise.

Description

Logical disjunction action.

The or function employs short-circuit evaluation: if the first argument is true, the second argument is not evaluated.

Truthy and Falsey Values

Like in many programming languages, FRED's numeric expressions can be evaluated as either true or false. Values that evaluate to true are considered "truthy", and values that evaluate to false are considered "falsey".

In FRED, a value of 0 is falsey, and all non-zero values are truthy.

Examples

state A {
    wait(0)
    if (or(age() < 20, age() >= 30)) then next(Selected)
    default(Excluded)
}
The above moves all agents that are not in their twenties to the state Selected.

See Also