|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序, G r! I) \/ m6 W1 q7 B3 r
其中有一段如下1 ~$ T) ?7 b8 b6 g# D# ?' G
ask turtles with [ infected? = true ] % y# y% ]" v" n
我原本以为这句会回传『所有』infected? = true 的 turtle
; f) o( D, j" m4 O6 J9 T& \: A" {但看结果似乎不是这样。
8 V9 B/ l, q1 c. X: l/ [ O# d1 g8 o0 q1 P3 X6 Y
假设所有符合条件的有 5 笔
5 ~& m- F6 c6 K有时候回传 1 笔,有时回传 3 笔,是不固定的
2 q% j) K* Q, t回头查语法定义
0 c) y; c9 N- s& t2 w" l' D$ xwith
+ H, g, j* W9 ragentset with [reporter]
) F; _6 A5 p( v( ?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 i7 Z0 {1 B! x+ `4 {/ e它只说回传 agents satisfying the given condition
9 m& s' f+ V1 j2 r: a* H是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 7 X4 C7 j! Y1 Q3 k0 M
5 }! i! p/ p( w- t: w& _
想确定一下$ N: J3 o' Z; R/ X
谢谢!
* k/ a: a; J' X% }2 D* [ |
|