|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
# e1 S* _$ _+ J其中有一段如下
0 w! O$ I" \9 ^/ _- H+ rask turtles with [ infected? = true ] 4 k+ @; S! Z$ `7 `% f7 Q
我原本以为这句会回传『所有』infected? = true 的 turtle- z1 U: t# U" v1 @! t( z8 O
但看结果似乎不是这样。
: D2 [( Q) {: B- K: r( q! {0 ~
: B& y- A5 D9 u: Z, k) R假设所有符合条件的有 5 笔; Q2 V" |) c( W2 c* }+ D, W% \
有时候回传 1 笔,有时回传 3 笔,是不固定的+ _3 O B6 Z' ?6 J, P* R2 S
回头查语法定义, n2 u& m( S: g, k% c; a
with
3 n ?# O3 n2 k/ X$ t' E& ^agentset with [reporter]
1 Z B' u; S1 X0 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.6 `+ ]" z: e4 `- W1 a7 U8 J: ?# |
它只说回传 agents satisfying the given condition
6 E) G5 V1 N5 n! G, r是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? , N; F# N* ^, G4 G. k! @( u
6 J' ?* ]) ^, @* f
想确定一下1 S/ P& P6 m# d. r5 i* [; p" j
谢谢!
3 u: V% U! X! l" r c; L; U' { |
|