NetLogo Cf Extension

Primitives

cf:ifelse cf:ifelse-value

cf:ifelse

cf:ifelse condition consequent conditions/consequents optional-else

Runs the first command block following a true condition:

The above code will print out x is less than 4! since that’s the first case with a true condition.

A final command block without a matching condition may be provided, in which case it will run if no other command blocks do. If no such command block is provided and no conditions are true, nothing will happen.

The default number of arguments is 3, so that if you only have one condition, a consequent, and an else block (like a regular NetLogo ifelse), you do not need parentheses:

cf:ifelse-value

cf:ifelse-value condition consequent conditions/consequents else-reporter

Runs the first reporter following a true condition and reports its value:

The above code will report x is less than 4! since that’s the first case with a true condition.

Unlike cf:ifelse, the else-block is required in cf:ifelse-value. If no condition is true, the result of the else block will be reported.

Note that cf:ifelse-value has somewhat different associativity than NetLogo’s ifelse, making it so that you don’t need to put parentheses around the conditions, as in the above example.

The default number of arguments is 3, so that if you only have one condition, a consequent, and an else block (like a regular NetLogo ifelse-value), you do not need parentheses: