|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序( `2 i& M; ?, @4 p8 e1 U
其中有一段如下
" p$ K4 w- \' o5 kask turtles with [ infected? = true ] . |) \) R2 \0 F- t* q: K
我原本以为这句会回传『所有』infected? = true 的 turtle
: C! |: T G: q. L$ A/ ]7 \但看结果似乎不是这样。
" n( W7 L! {6 T6 I8 G0 ~4 C& @
8 q# s; U& n. n L. V假设所有符合条件的有 5 笔6 O2 Q9 s( a0 y9 B$ ]( d' g. R
有时候回传 1 笔,有时回传 3 笔,是不固定的! W8 g9 B" l. t/ t
回头查语法定义
/ ]5 ^. h4 d9 \with ' W. P# c" X: U7 j
agentset with [reporter]
! u& }# h0 _1 |2 b) A( u$ TTakes 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.$ \4 m* \3 T, T* c( t
它只说回传 agents satisfying the given condition
. ~7 ^* N% e! s是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 6 @3 c( H K5 J; [/ x
) D9 d1 v) d( R9 N9 T
想确定一下$ G3 _3 X, r% h+ k) V( V
谢谢!
- K) q) P: H* @8 ? |
|