|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
0 h, C- G: a% M其中有一段如下
: X0 A+ X4 H7 t! C8 @ask turtles with [ infected? = true ] % K" L' i% {5 t1 n0 k
我原本以为这句会回传『所有』infected? = true 的 turtle
# ^5 F7 d4 I! z( K; T/ M K- V4 T: P) o但看结果似乎不是这样。/ F4 q$ q+ g3 w1 n* V; |+ x
- O) D" [; m2 t# B: G
假设所有符合条件的有 5 笔
5 O( U3 n& _0 H: ]; |9 r }有时候回传 1 笔,有时回传 3 笔,是不固定的
9 }4 U0 J! h! T( P回头查语法定义+ D/ X3 t! f' V0 h9 M$ f) s
with 6 ^/ R8 g& i% }
agentset with [reporter]; p) g+ l7 W1 g% l l8 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.
0 e- V T6 z, T+ f它只说回传 agents satisfying the given condition$ r$ E; M$ B% F3 l$ i! k
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 5 R; u i m$ _/ {5 l w) S
) b/ ?- L6 o+ v. N* q5 O" C/ V想确定一下4 H2 F0 ~4 h# T# j- z, f& K
谢谢!
: `" V1 e1 q6 @* ]7 e C# q' U) X |
|