|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
( M" |" r8 x$ Z5 r$ I其中有一段如下
& w7 w. Y; B4 f. o" c( |& S7 hask turtles with [ infected? = true ] . a* A E% z) C/ v
我原本以为这句会回传『所有』infected? = true 的 turtle
: i, C- f* l9 M0 C' y @但看结果似乎不是这样。
" A8 Q6 L7 o7 k0 D" h
" N- K, ~9 e4 t4 [6 O假设所有符合条件的有 5 笔6 w3 y0 t8 ^' p% j* t5 d
有时候回传 1 笔,有时回传 3 笔,是不固定的
# Q" h/ T# I* z% w; f回头查语法定义3 B4 T8 c) k: u; m( N
with 9 |+ H' B; w% J) S* }3 U! S1 ]
agentset with [reporter]! a3 A: \3 P- G' J }: o
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.( T4 y3 |& p8 g% V' [7 G7 c, t
它只说回传 agents satisfying the given condition9 T5 {* e- H( m+ {0 M
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 5 Z; M% j6 U+ q, c# z6 n
D9 _; j* w$ y. Q1 w
想确定一下
& T3 W+ F3 O4 b- I7 Z: b% H谢谢!9 l8 j! Z. u) |6 Z* u! w+ O
|
|