|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序7 u, h9 T! f/ n1 m' H }
其中有一段如下
* v, ~' N( i& G G& t& zask turtles with [ infected? = true ]
2 I! q; q& i/ t, R, h我原本以为这句会回传『所有』infected? = true 的 turtle% ?/ x9 W* o7 |0 J) q2 m
但看结果似乎不是这样。
) D% B0 Z' G" R) }2 W, J- ~, d7 Z4 M: u( B: Q; |# O/ U9 R
假设所有符合条件的有 5 笔" U( S& r/ k/ i! K
有时候回传 1 笔,有时回传 3 笔,是不固定的0 L; T9 ?1 i. ]8 o0 f; t' E
回头查语法定义( n k) o% J/ K8 b3 s% T
with
/ p' U% ^$ k- J! @% B* Y$ Xagentset with [reporter]2 n" r6 |9 ^3 k* C$ Y% P0 d
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.
! ^& L) l) C6 C- D( J% W1 f9 Z它只说回传 agents satisfying the given condition
# G2 P1 V: i/ D+ w* T4 K是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
% b8 w! Q* n& V; l7 ]5 H! _, O0 S' m8 p6 e+ G: a, I2 d
想确定一下* k# F$ o1 B6 M% w% W- e
谢谢!6 q% {; V6 Q' }
|
|