|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序& {2 O4 j0 A3 \: F
其中有一段如下
/ W0 B7 c4 y! Eask turtles with [ infected? = true ]
$ `" ], r' ^1 {2 @我原本以为这句会回传『所有』infected? = true 的 turtle/ u4 L @8 R# u, ?: T2 Y
但看结果似乎不是这样。
|0 z0 v$ n* }$ X) }6 I
; e4 _' f5 ]+ e9 c; |/ D4 I假设所有符合条件的有 5 笔
$ I, Y4 k2 Q% U d# c5 O1 s& N有时候回传 1 笔,有时回传 3 笔,是不固定的& \, G$ X5 @% A& s+ r
回头查语法定义* j6 {5 V, o" r. j, ~9 j& R1 ^
with
- L, Y+ q2 Y1 Q4 o% Iagentset with [reporter]- W" J% m, y7 G: i- J7 ~! K
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.6 `* O5 P' w2 p( \5 H- c6 U
它只说回传 agents satisfying the given condition
5 Z6 M7 {% l1 G8 f) c `是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? / Y ] Z$ ]% o, D) B) L2 }
2 T7 Z! }! Q1 p1 m$ g
想确定一下
, g3 ], M6 I' a谢谢!) [( E. i- u0 X! S3 ~3 ?4 D
|
|