|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
! u5 q( K, X& L4 ?其中有一段如下
; d9 ]7 g3 `% S' pask turtles with [ infected? = true ] 6 f$ a/ m. R0 J7 P' |' t# e8 Z
我原本以为这句会回传『所有』infected? = true 的 turtle
* V+ z; e" H$ J% d- z但看结果似乎不是这样。
. f+ ]4 \: ?5 ~6 M7 M6 d. p/ L
9 D6 N ~5 h! s, p+ F9 H假设所有符合条件的有 5 笔2 U+ Q7 y3 z9 `, n6 c* |4 V. N
有时候回传 1 笔,有时回传 3 笔,是不固定的* W' ^8 l) \6 A- ?2 T
回头查语法定义
4 [, F! j0 A: g4 fwith ( T, d' Y& n* _$ `0 c( N* d
agentset with [reporter]
/ D8 `: B/ n5 k0 Y3 ^/ x: S( QTakes 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.
0 M! C/ K, T" S; e6 h3 r7 q它只说回传 agents satisfying the given condition$ t1 Y2 x/ m; T. P
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 6 g0 c( ^ a, C! U* X
! V/ Y& Q. J! K* k
想确定一下
! f8 Z* e2 q( m9 t/ F4 `: S9 j谢谢!
_; c' L8 Y8 G4 i1 a) f2 `/ f |
|