average-of-turtles-with
[condition] [list of commands]
Parameters:
[condition] |
List of turtle commands |
An expression that returns a true or false value |
[list of commands] |
List of turtle commands |
A list of commands for the turtles to run which returns a number |
Description:
Returns the numerical average of the [list of commands] when evaluated across all the turtles that satisfy the conditions (must return a boolean of true or false) specified by the [condition].
Examples:
average-of-turtles-with [color = red] [energy]
returns the average energy of all the red turtles.
Notes:
If [list of commands] contains no numbers, an error occurs. If some of the [list of commands], when evaluated, are not numbers, those values are ignored.
When a turtle calls the command, it, itself, is not included as part of the calculation.
Related Commands:
average-of-breed-with
median-of-turtles-with
min-of-turtles-with
mode-of-turtles-with
sum-of-turtles-with
variance-of-turtles-with