|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
8 M# l! B+ }# U: O6 x7 Q( P其中有一段如下
. l) W+ ? h' J1 sask turtles with [ infected? = true ]
# B0 w+ G: v7 d$ r' g. u2 u我原本以为这句会回传『所有』infected? = true 的 turtle
( B+ M1 D$ y* t但看结果似乎不是这样。: D5 F- d) M+ h- E" \ S
3 G' M5 P. n; F* L- l8 d- S6 c
假设所有符合条件的有 5 笔( ?6 v2 g1 e& ]
有时候回传 1 笔,有时回传 3 笔,是不固定的( L$ _7 ^8 S8 ~0 p r6 ~
回头查语法定义
9 b7 M& ?2 B4 M6 p/ F pwith
( E2 x( B# c: ?) ]agentset with [reporter]
# P; L6 N8 C3 O. E. s/ g' mTakes 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.
5 i: ]( d4 x0 `9 m; M6 V0 p它只说回传 agents satisfying the given condition1 I: I+ O% a* o- b
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 5 A- j: A9 y: g- j7 c+ d ?
$ c" f5 e& x4 w想确定一下
4 S8 o/ a$ Z) p谢谢!
; k2 h3 h! T1 h `7 Y$ z |
|