|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序# f3 R$ \) W. F/ B: N$ w
其中有一段如下
& Y! j0 O3 a" Vask turtles with [ infected? = true ] 8 a/ T& ?6 I( }$ W5 L
我原本以为这句会回传『所有』infected? = true 的 turtle, g1 V( ?7 M' D+ i+ A; U
但看结果似乎不是这样。4 k# L6 Y# O* q9 }5 s& Y
( `- Z- f7 M7 R) u: }假设所有符合条件的有 5 笔* ^6 Z& j* ^% p1 d
有时候回传 1 笔,有时回传 3 笔,是不固定的
2 I; \4 p' t, s% m3 z, \+ q回头查语法定义
+ u& J: E5 A( Q3 r5 r+ N- Iwith & U* f5 g; o) E
agentset with [reporter]
6 H# H2 s$ Y& S1 E' QTakes 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.
. z8 v8 ^( K6 I: ^) e- B它只说回传 agents satisfying the given condition
% B, ~6 D0 {- y% C" |! s是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
) u; T1 q) h& M1 Z& h/ `& ^* F) J9 g$ Z" \% f: P' c, T
想确定一下; A- {/ ~4 S4 p6 @6 Y4 b
谢谢!
7 p1 D4 t& M6 h" o# S |
|