|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序1 B& r0 ^0 }0 d) ]! P
其中有一段如下
& F% Z c% Q$ A+ o+ R& S+ @. k0 `ask turtles with [ infected? = true ]
1 m- r# ~* G( N& Q5 K我原本以为这句会回传『所有』infected? = true 的 turtle
# {" p$ v5 }, M0 W" {但看结果似乎不是这样。9 T6 U. k( x* N$ \2 G/ t
" Q! n: r6 l) y; D y
假设所有符合条件的有 5 笔
1 V' x5 J' O# n/ n& C有时候回传 1 笔,有时回传 3 笔,是不固定的) v; `. r; _. `# B$ _0 `9 y
回头查语法定义
$ S) Y2 a ?& D+ xwith
) f9 f& ]/ U6 yagentset with [reporter]
; q y5 I% ~" u" vTakes 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." e8 ^' n, v) s6 M# F
它只说回传 agents satisfying the given condition
- F+ }4 X. J( L! w是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
) L' ?- B5 s5 K* Z2 | N3 s5 Q: b& V
: {( H$ Z4 C" V8 ?( ?. Q" v想确定一下
0 Y' v3 g4 i& I' G谢谢!6 O9 A$ m( I) ^ B L
|
|