Download NetLogo 2.0.2 User Manual - Center for Connected Learning and

Transcript
NetLogo 2.0.2 User Manual
=> [1 2 3]
show map [? * ?] [1 2 3]
=> [1 4 9]
With multiple lists, the given reporter is run for each group of items from each list. So, it is run once
for the first items, once for the second items, and so on. All the lists must be the same length.
In reporter, use ?1 through ?n to refer to the current item of each list.
Some examples make this clearer:
show (map [?1 + ?2] [1 2 3] [2 4 6])
=> [3 6 9]
show (map [?1 + ?2 = ?3] [1 2 3] [2 4 6] [3 5 9])
=> [true false true]
See also foreach, ?.
max
max list
Reports the maximum number value in the list. It ignores other types of items.
show max values−from turtles [xcor]
;; prints the x coordinate of the turtle which is
;; farthest right on the screen
max−one−of
max−one−of agentset [reporter]
Reports the agent in the agentset that has the highest value for the given reporter.
show max−one−of patches [count turtles−here]
;; prints the patch with the most turtles on it
mean
mean list
Reports the statistical mean of the numeric items in the given list. Ignores non−numeric items. The
mean is the average, i.e., the sum of the items divided by the total number of items.
show mean values−from turtles [xcor]
;; prints the average of all the turtles' x coordinates
174
Primitives Dictionary