Turtle, Observer, Patch

sum-of-turtles-with [condition] [list-of-commands]

Parameters:
[condition] List of commands list of commands which returns either true or false
[list-of-commands] List of commands list of commands which returns a number

Description:
Reports the total value of [list-of-commands] when run over the turtles that satisfy [condition]. If there are no turtles in which the [condition] is true, returns 0.

Examples:
sum-of-turtles-with [color = red] [age] returns the sum of the ages of all the red turtles.

Notes:
This command can also be executed by patches, for example within an ask-patches statement.

Related Commands:
average-of-turtles-with max-of-turtles-with median-of-turtles-with min-of-turtles-with mode-of-turtles-with sdev-of-turtles-with sum-of-breed-with sum-of-turtles variance-of-turtles-with