map1.3

map reporter list (map reporter list1 ...)

With a single list, the given reporter is run for each item in the list, and a list of the results is collected and reported. reporter may be an anonymous reporter or the name of a reporter.

show map round [1.1 2.2 2.7]
=> [1 2 3]
show map [ i -> i * i ] [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.

Some examples make this clearer:

show (map + [1 2 3] [2 4 6])
=> [3 6 9]
show (map [ [a b c] -> a + b = c ] [1 2 3] [2 4 6] [3 5 9])
=> [true false true]

See also foreach, -> (anonymous procedure).

Take me to the full NetLogo Dictionary