|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序/ U+ a' ?: {& o- Q( Y
其中有一段如下
3 R- r3 P9 ~5 O' F. y9 Aask turtles with [ infected? = true ]
9 a" S3 n3 k7 N- L5 C: ` }/ ~我原本以为这句会回传『所有』infected? = true 的 turtle
: y" F: }3 L3 L. V但看结果似乎不是这样。( j: _$ B: s* W( p6 _0 z
# ]% m& C. T& ~8 ^$ V
假设所有符合条件的有 5 笔
. r: g/ V6 N: y n" m$ I/ q有时候回传 1 笔,有时回传 3 笔,是不固定的2 S6 k1 u$ C8 I& G$ z
回头查语法定义& Z8 G8 w n0 \4 I2 t) P, n
with
0 R! t' R3 `7 Sagentset with [reporter]
6 c U% v& R: i! tTakes 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.
9 n) C+ D# U. V3 W* Q4 b它只说回传 agents satisfying the given condition( w `3 k! R4 _- T6 D# S0 D
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? : f- A' C& `! \" [
. N* g: n" i# ~- p% S0 \
想确定一下
" i H8 Z' c0 \5 C) u谢谢!
% S* X$ S; F5 n* C# C& ~9 Y |
|