|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序; X; w1 M7 ~2 t* p
其中有一段如下
! p# o3 g' |! y3 g3 s$ Zask turtles with [ infected? = true ]
6 N M; ]( t- ~3 ~, B) O我原本以为这句会回传『所有』infected? = true 的 turtle- u' O S: F2 V7 P7 n
但看结果似乎不是这样。
, ?$ G# m M( i2 d$ R6 e) t& I
9 v; c, c& U4 q: @( x' R假设所有符合条件的有 5 笔
) _! U* p4 R/ L9 r4 @有时候回传 1 笔,有时回传 3 笔,是不固定的& N2 [6 c* L! U. E
回头查语法定义
2 U( [6 S2 K4 }/ F. |6 ^# U/ _with 2 _& }6 V C; C
agentset with [reporter]5 D2 B' A% F% V
Takes 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 C* d, V. Q0 z4 H. P
它只说回传 agents satisfying the given condition8 }; V7 p, g. E
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 6 Q8 Z' o/ b9 c- Q( k& Z/ [5 t
/ N0 m+ D! e+ G. m+ p想确定一下6 i0 ]4 N$ y6 k/ j% ~2 z6 J- L$ d
谢谢!
, J% \5 v2 F' z+ L- y |
|