|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序- @4 E* i2 O7 k( G( T6 Q# d
其中有一段如下
O7 e0 m# ~$ u: }) q3 y: eask turtles with [ infected? = true ]
) O: }1 t* S% c我原本以为这句会回传『所有』infected? = true 的 turtle& {+ L$ H0 i9 Y
但看结果似乎不是这样。
) e2 F) k: d$ D" q3 e; V3 ~, G% k. _5 u, ~+ x" l! I* E
假设所有符合条件的有 5 笔; Z- U! L5 d0 a! n
有时候回传 1 笔,有时回传 3 笔,是不固定的/ G" d/ t0 u, H" X: u' L
回头查语法定义" n0 d+ T# p& a2 F0 Q5 f7 d! }: x
with : h Q/ J" ~- L! H/ p' c
agentset with [reporter]2 S0 S# }4 F! K& k, m
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.
. v. F7 p! P6 e7 _6 H它只说回传 agents satisfying the given condition5 L( G0 r1 `8 I3 C9 |" k
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
( R W+ s( |9 F
! \6 S5 f5 x o" r* M- r想确定一下+ W/ u6 a/ L, E T; ~9 y' y
谢谢!, h+ z: k- _- }% o
|
|