NetLogo:如何对列表执行多项操作(查找,获取,替换,删除,搜索列表中的元素,....) [英] NetLogo : How to do multiple operations on lists (find, get , replace, remove , search elements within lists , ....)
问题描述
我是NetLogo的新手,我想知道是否有完整的参考资料来对列表进行操作,除了Netlogo词典以外,我还阅读了此处的大多数文章,但是例如,如果我需要像这样的数字对列表,
I am new to NetLogo and I was wondering if there is a complete reference to do operations on lists, I have read most of the posts here in addition to Netlogo dictionary but for example if I need a list of pairs of numbers like
[[1 2] [2 2] [2 3] ,,, ]
搜索时
member? 3 thislist
我是否可以选择说要考虑进行搜索的内部列表中的哪个元素?例如,如果搜索第一个元素,我将得到false;如果搜索第二个元素,我将为true.
Will I have the option to say which element of inner list I am considering for the search ? for instance I will get false if it search first element and true if I search second element.
有人可以澄清Netlogo中列表的使用吗?
Can anybody please clarify the use of lists in Netlogo?
推荐答案
map
,filter
,reduce
,foreach
,n-values
和sort-by
使用任务在列表上提供可自定义的操作.请参见 http://ccl.northwestern.edu/netlogo/docs/programming.html#任务.
map
, filter
, reduce
, foreach
, n-values
, and sort-by
provide customizable operations on lists, using tasks. See http://ccl.northwestern.edu/netlogo/docs/programming.html#tasks.
这是您使用map
的示例:
observer> show member? 3 map first [[1 2] [2 2] [2 3]]
observer: false
observer> show member? 3 map last [[1 2] [2 2] [2 3]]
observer: true
这篇关于NetLogo:如何对列表执行多项操作(查找,获取,替换,删除,搜索列表中的元素,....)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!