|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序: S* k" X# \% l1 W
其中有一段如下( s8 \- [3 Z% z7 {" y
ask turtles with [ infected? = true ] " Y _( o9 w7 }4 ^, w- F7 `
我原本以为这句会回传『所有』infected? = true 的 turtle: o2 D6 D! |3 |
但看结果似乎不是这样。7 y* y1 Q; a9 N1 L
& D2 I; z% h9 D1 T1 o7 l! @
假设所有符合条件的有 5 笔- F T* Z* w+ d9 a# F! Y8 E9 G+ c+ ]
有时候回传 1 笔,有时回传 3 笔,是不固定的
& n, v; y; m' O" r* S+ V: U8 w回头查语法定义9 t. ]7 P4 a9 P
with
/ l6 j+ o( \+ Dagentset with [reporter]
, D; d; _5 P- j6 c; k# f, _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.: K% m3 a; v: s) r$ L
它只说回传 agents satisfying the given condition
0 X! ]+ ]! T ]是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? " v* P2 X- s- X
* b" d! D" S: L* x/ | n想确定一下
+ g1 {/ _5 D" r' Y谢谢!
+ e; C% Z( T$ L- u |
|