|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序5 n# a) e# c* x! y
其中有一段如下9 o. t- [3 I! @: Q0 N. i
ask turtles with [ infected? = true ] ' R: J- d c! \" R2 }
我原本以为这句会回传『所有』infected? = true 的 turtle
5 R. U, o6 K" M8 F但看结果似乎不是这样。: L/ H6 t7 @# k( @- ?/ O9 j5 {
) j# Q7 R& u7 X8 a: [( N
假设所有符合条件的有 5 笔
8 \' ]0 L% y; D有时候回传 1 笔,有时回传 3 笔,是不固定的3 I( f" S, i* }$ L
回头查语法定义
( v0 o( Z' w" |! Pwith
6 X2 g8 _ x# {& F5 K4 e* Y( gagentset with [reporter]
& F: K- p+ ~# jTakes two inputs: on the left, an agentset (usually "turtles" or "patches"). On the right, a boolean reporter. Reports a new agentset containing only those agents that reported true -- in other words, the agents satisfying the given condition.3 e- F3 J" F! q! K& P! E. p1 `( f
它只说回传 agents satisfying the given condition( }% }2 P/ H7 n' E9 R) m6 j/ D
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 1 l# V7 ]9 @+ k, Y
$ V$ C! u' I$ a0 w, w# }- x) v想确定一下
, K9 @" g+ B2 S7 s& M谢谢!5 u. [$ n2 r6 _& ~! y; t
|
|