|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
" {4 I& Z: b( y1 g+ E其中有一段如下
, E' w: J- r2 C! t& Bask turtles with [ infected? = true ] ' n" u p4 {, Q. S9 b5 _- C
我原本以为这句会回传『所有』infected? = true 的 turtle
/ s4 |" E3 `7 O9 T* Z% |2 h1 w但看结果似乎不是这样。
) k9 M4 |. ^. O5 d4 ]
3 ^% y, s2 W* R6 k假设所有符合条件的有 5 笔
. z3 O+ H7 d0 ~" r. |. o( I有时候回传 1 笔,有时回传 3 笔,是不固定的+ j( ]0 }( E+ \6 R
回头查语法定义1 v0 T& F$ L' g \% o& e, m' d% U
with - s1 B/ i# f$ i/ x1 E& s% M8 d) |
agentset with [reporter]" P8 D+ }1 U# o/ e' k& \
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.+ Y! C6 v4 p7 \
它只说回传 agents satisfying the given condition% b8 T. X. B2 g3 D# l |
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? * E: Y, k/ V1 s" x
1 i3 e. f( N4 X+ f) k4 y想确定一下7 I9 O# {1 C! \
谢谢!
2 x' g6 G' I5 h9 L7 H, h& L |
|