|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
/ V6 Z7 r. _# m C$ c其中有一段如下
$ k" N( k3 T! f; `: G1 iask turtles with [ infected? = true ] 3 R) \6 H# N4 e6 p
我原本以为这句会回传『所有』infected? = true 的 turtle
$ K6 [ C* K6 L但看结果似乎不是这样。$ r a Q% [ o2 h% y
% X' ^) j& q$ L
假设所有符合条件的有 5 笔
$ X" N+ t8 ~$ k: g' ?/ a有时候回传 1 笔,有时回传 3 笔,是不固定的 [3 }, s8 c5 E3 E5 S3 T T, L
回头查语法定义
7 o" O) D4 \* `5 @, T* W @9 mwith 7 Z+ T# K% A: Y" a- i: j
agentset with [reporter]
/ O( M4 S; }4 I" O* i- x6 ?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.7 m% B) Y2 Q9 {, _& A( u
它只说回传 agents satisfying the given condition
' k1 Y- }$ s; J/ a g$ W是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
# M" D( r9 A0 U. V! Q+ @) v# j( t/ \+ D {
想确定一下
% W* G1 u7 |. e) ~5 v0 x* `谢谢!4 h( C, d0 m& T8 o! `. n" C
|
|