Turtle and Observer Command

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

Reports the total value of [list of commands] when run over the turtles that satisfy the condition. If there are no turtles in which the condition is true, returns 0. Note: This command can also be executed by patches, for example within an ask-patches statement.

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

Related commands:
sum-of-turtles