|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序$ \. q j9 Q8 X5 D$ ^+ }/ a
其中有一段如下5 Z. k# u' G; I* F7 n3 I
ask turtles with [ infected? = true ]
* F3 e0 S, m9 N; O我原本以为这句会回传『所有』infected? = true 的 turtle% o1 g3 S6 @4 N' r" V
但看结果似乎不是这样。
\2 Q: c4 L- \* I. c( V2 J5 F4 K' W; I1 e1 K. a+ b
假设所有符合条件的有 5 笔
5 Q4 s) h. ^' u3 h: W有时候回传 1 笔,有时回传 3 笔,是不固定的
: L, [% ]& X& j4 F/ h0 B5 _回头查语法定义
, i. c$ @+ y# O9 M6 F+ U: ?+ Fwith
m$ z9 d/ S; X6 R) |agentset with [reporter]0 E/ c6 S! T8 u) w! e6 t
Takes 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.2 b, d: t( Y6 S% x1 s" O
它只说回传 agents satisfying the given condition9 S; [; t2 X! l. Z& Q
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? , P `' f+ {4 m; o$ y! _* O
4 W& ]3 k% Z0 v
想确定一下
1 c E9 e5 F, Y) b4 ^谢谢!
; m& |% H; ?! V; F9 H6 Z- N. N* ? |
|