filter

filter [reporter] list

Reports a list containing only those items of list for which the boolean reporter is true -- in other words, the items satisfying the given condition.

In reporter, use ? to refer to the current item of list.

show filter [? < 3] [1 3 2]
=> [1 2]
show filter [first ? != "t"] ["hi" "there" "everyone"]
=> ["hi" "everyone"]

See also map, reduce, ?.

Take me to the full NetLogo Dictionary