Skip to content

and

Syntax

and(boolean_expression_1, boolean_expression_2)

Parameters

boolean_expression:
A numeric expression that is to be evaluated as truthy or falsey.

Returns

Returns 1 (true) if both expression parameters are truthy. Returns 0 (false) otherwise.

Description

This is a logical conjunction action.

The and action employs short-circuit evaluation: if the first argument is false, 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 (and(age() >= 20, age() < 30)) then next(Selected)
    default(Excluded)
}
The above moves all agents in their twenties to the state Selected.

See Also