|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
( l2 e% q0 o! j4 b. U$ `其中有一段如下
1 t, d' G* z7 t3 V# g% jask turtles with [ infected? = true ] % a- k& t5 J. |& T- V
我原本以为这句会回传『所有』infected? = true 的 turtle
. |9 @1 ^/ D X; d8 I但看结果似乎不是这样。9 e6 \+ P" C9 r1 u
" Q# M5 N3 {0 y; E; v# O
假设所有符合条件的有 5 笔
3 O( l% M) G2 r8 k6 H有时候回传 1 笔,有时回传 3 笔,是不固定的
^3 `7 C! D. k/ R' \7 Y7 z回头查语法定义8 o9 S( W( K5 p5 t( ^; {
with & O7 z( C+ t( n9 Q0 L
agentset with [reporter]
, V4 z! O% C/ 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.
$ [7 ]; L" Q( e8 t2 B( K. s它只说回传 agents satisfying the given condition3 ~- S; T! G2 Z
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
2 C* d3 |1 ]9 p+ V- W8 _
. g1 ~8 v* q4 _想确定一下3 d3 Y+ _9 X9 X
谢谢!
; y) T" w/ O& x" y r: u9 K* `7 X9 u |
|