|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
/ @" ~) |$ d- J. Y5 F$ h其中有一段如下
" v1 I4 L2 O, e4 d+ n2 ]$ Iask turtles with [ infected? = true ] # I, @5 b* {4 S+ R/ `
我原本以为这句会回传『所有』infected? = true 的 turtle
o0 r+ E* C T$ Q但看结果似乎不是这样。' m. ^; G# q! ^' b+ }
( H. }; e/ u# J1 e: Z: s! u
假设所有符合条件的有 5 笔
' ^+ X+ ?+ v3 ? V- ]2 u( C% S有时候回传 1 笔,有时回传 3 笔,是不固定的- w" p& A- Z2 A8 {
回头查语法定义9 P7 k# D& Y, w Z2 N
with
+ M) O1 p: e6 y7 Y6 M ~agentset with [reporter]. y4 y% T+ _( {( x. _
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 y* }" f3 x$ R( H它只说回传 agents satisfying the given condition1 ]4 D. M; Z8 i7 [9 m8 ?# ]: ?3 J
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? " g0 ^/ J' a! n7 p9 t' E
- T: E) C8 s& J. s* _想确定一下
+ Y+ D* P0 q* v6 I) G1 _& y谢谢!
p( Q6 ]; a; `( k |
|