|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序( f- l6 m, J0 C; d4 R0 o& Z
其中有一段如下& ^" H+ |; @4 |9 Q- |8 k/ c) N
ask turtles with [ infected? = true ] 7 G8 _: D) C8 J8 i$ n8 y3 h" O: q
我原本以为这句会回传『所有』infected? = true 的 turtle, S9 ^" v0 O/ `: g
但看结果似乎不是这样。
7 S2 |) ?2 N2 I2 D' f* E/ x
y+ z- R! s6 _ H" S2 b* ?) ^假设所有符合条件的有 5 笔6 C! s7 E8 F; @+ W
有时候回传 1 笔,有时回传 3 笔,是不固定的
) j+ y$ y# U1 _2 K- C回头查语法定义
: s% u- a: Z. r$ u) zwith
P5 t2 d. E- i: F6 f( \agentset with [reporter]6 E+ u" k: I' A( A' c1 B8 [
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.
+ ~( ]# M4 `' o它只说回传 agents satisfying the given condition3 r: @/ H# q; b0 [' X; \3 [3 {1 ^
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? & M# }2 ?8 u; X% C3 `
+ X" x1 a. I }想确定一下
. i4 d( D1 I1 l4 d3 h, k% V谢谢!
) m; j) _) l% U: A k |
|