Search code examples
listdictionarynetlogoagentset

How to MAP over agentset?


I need to iterate over a specific agentset of patches and get the neighbors of them all and then join those...

I'd do something like

reduce patch-set (map [patch-set neighbors self] patches with [somecondition?]) 

But MAP and REDUCE won't work on agentsets!


Solution

  • The normal idea of a map does not really make sense for a set, but you can produce a list with of, and then convert it to a patch set.

    let _nbrs patch-set [neighbors] of mypatches
    

    You filter either mypatches or _nbrs with with on any condition you wish.