neq¶
Syntax¶
Parameters¶
x1: numeric-expression- left-hand argument.
x2: numeric-expression- right-hand argument.
Returns¶
Returns 1 if x1 is not equal to x2, 0 otherwise.
Description¶
The "not equal to" action. This is equivalent to the infix form x1 != x2.
To use a numeric comparison operator within an expression, you must use the functional version of the operator. For example:
x = x + neq(age, 10) # adds 1 to x if age != 10
x = x + (age != 10) # will result in a fred_compiler error message.
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¶
Agents with an age not equal to 18 can be filtered into the state Select with the transition rule:
or with the infix form: