Skip to content

eq

Syntax

eq(x, y)

Parameters

x
A numeric expression that represents the first value.
y
A numeric expression that is compared to the first value.

Returns

Returns \(1\) or true if x and y evaluate to the same value, and \(0\) or false otherwise.

Description

Determines whether two values are equal. This action returns 1 (true) if the two arguments' values are the same, and 0 (false) otherwise.

This is equivalent to the infix form x == y.

To use a numeric comparison operator within an expression, you must use the functional version of the operator. For example:

# This is valid, and adds 1 to a if the agent's age is 10
a = a + eq(age, 10)

# This is not valid, and will result in a compiler error
a = a + (age == 10)

Examples

Agents with an age equal to 18 can be filtered into the state Select with the transition rule:

if (eq(age, 18)) then next(Select)

This is equivalent to the infix form:

if (age == 18) then next(Select)

See Also