|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
* H3 B' b% D' Q" l! N$ t其中有一段如下( u' n+ E o y0 m0 L$ X u
ask turtles with [ infected? = true ] , c( k% Y$ V$ v
我原本以为这句会回传『所有』infected? = true 的 turtle L8 o1 k' F! L* C% B
但看结果似乎不是这样。& ?0 K" ~! y% i. x
' A/ h; g2 s9 b) {. Q$ m- f" I
假设所有符合条件的有 5 笔
) X0 L) N2 a3 E4 w8 y有时候回传 1 笔,有时回传 3 笔,是不固定的3 j) ]) q7 \" A- t: I
回头查语法定义1 s$ g; d- Z2 F K' s8 u
with
* ^4 p1 F% ~5 l) ?7 T0 Y' Vagentset with [reporter]
9 ^6 ^2 `+ L5 M& L' y- m$ 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.+ t0 L1 Z$ N+ z
它只说回传 agents satisfying the given condition& ~9 `$ ^0 V/ @7 n% r
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
i4 N* E) U U! m+ G/ L v& l3 r, {. D, t
想确定一下+ M8 x; u# R$ g0 X6 `9 x4 j2 ]& X% e, A
谢谢!5 X3 g6 y5 |7 k2 [ J# A3 R7 V
|
|