|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
& V! z6 P( s3 P5 H7 `# G其中有一段如下
" w! {( ~8 l; n6 L; aask turtles with [ infected? = true ] 9 i' q- p2 F6 F5 ]: c( P t$ Q" Y( x+ D
我原本以为这句会回传『所有』infected? = true 的 turtle% ~. B9 t+ y1 u* k! J7 C
但看结果似乎不是这样。
* Z( r! `9 q) u# V) a7 o" Z3 I4 J5 I' L& P
假设所有符合条件的有 5 笔
; t" J" u) E% a有时候回传 1 笔,有时回传 3 笔,是不固定的7 @9 m" o' c5 s9 V0 x
回头查语法定义+ N6 d; `- c3 B$ C: u$ \
with & x, ?3 [ b" X* y
agentset with [reporter]3 I2 B' W% a7 V" B. X- I5 ?
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.4 J$ ~( D# z, y& a, c0 V( D
它只说回传 agents satisfying the given condition
4 T/ }3 f0 G {2 X! t9 ]是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
* Z3 ?$ K, I9 t! Z# q5 K- m1 h# z. }% t9 y5 r% n4 D! {
想确定一下
5 a4 B9 Q; F0 b/ C: U6 k谢谢!
0 u. R% b8 k! C0 _0 g3 x' \. e& j9 J |
|