|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序! Z, {% e+ M# [/ g
其中有一段如下
9 u$ v) |9 I3 X& m. B- Y5 a" x A# P4 nask turtles with [ infected? = true ]
8 }/ a- H2 w+ w; p6 {! e) @0 Y我原本以为这句会回传『所有』infected? = true 的 turtle
( ?6 o9 ?) a7 X7 v但看结果似乎不是这样。
: N X" _% Z: Q, R3 }+ X1 \( G4 N; p2 X
9 t7 k" K [# q# u假设所有符合条件的有 5 笔& p$ | d' p" z/ V: }( l0 I$ K
有时候回传 1 笔,有时回传 3 笔,是不固定的
5 `' v5 a; r4 ^; A% S$ W/ A回头查语法定义0 `/ v: Y& o3 x4 s5 L$ Z( N6 F
with
) C# S. d8 y% Kagentset with [reporter]
) ^$ J* \$ h# ?2 }- h5 rTakes 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.5 N0 q+ ~9 f. ?: K* u* g* T
它只说回传 agents satisfying the given condition
6 Q' A+ }8 g: }; G0 w是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? / z t' ]$ b% Q+ A9 D+ e( J
/ ~' e e+ Q" N
想确定一下; W0 x; |. T) ~- J
谢谢!
; w! F9 x* J( \; t |
|