|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
) L& l& F& m" B. B1 N2 v* n/ j其中有一段如下
4 S1 {; U$ E1 h* D/ ] iask turtles with [ infected? = true ] 3 ^, F, }5 N. ]
我原本以为这句会回传『所有』infected? = true 的 turtle
$ J) m% v" m. }3 a% x& E但看结果似乎不是这样。! J l8 p4 l! g: w0 t% O
* f1 p/ K8 O0 r! c假设所有符合条件的有 5 笔5 J1 }: |3 l- R6 O, b9 K( U
有时候回传 1 笔,有时回传 3 笔,是不固定的- A5 |1 X2 V" n5 e% C+ B
回头查语法定义
8 i Q' \7 o5 T7 j' f/ Lwith 4 |' z' E$ S" U/ G# q
agentset with [reporter]
5 ^( Z/ ?! y) J" I7 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.* G. u1 t# z! q# `, [: G' V
它只说回传 agents satisfying the given condition8 Y/ n" g& J: L% y; g/ E
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? ) s4 e4 u0 h% X0 c' {% |
6 K5 x1 B' b6 Q6 }* J/ k想确定一下
# S$ e, F# E8 H7 r# _谢谢!
" i/ S* z% E. n* z |
|