|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
% W: L8 o1 C+ v# G8 @- b4 }1 W其中有一段如下
, N ^2 q6 o8 b$ h' `ask turtles with [ infected? = true ] 9 m1 K: d' q- ^/ p3 U- i$ u/ U
我原本以为这句会回传『所有』infected? = true 的 turtle, F( F9 u0 v# t0 t$ P( e
但看结果似乎不是这样。
0 L" D- S1 G- K/ Z& J* H) Z+ R$ o4 Z: D2 `
假设所有符合条件的有 5 笔
4 Z. ~! X1 |7 Y" Y* _有时候回传 1 笔,有时回传 3 笔,是不固定的
. O! w8 t! B n# w- l回头查语法定义
' F) q. U. s3 c/ p7 F( K+ Vwith
8 C3 {3 M, \6 p pagentset with [reporter]; R% e0 P) Q6 k1 Z
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.! q, s2 u, i/ ]* \' f
它只说回传 agents satisfying the given condition m4 z5 {* ^: [6 J' z: I
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
7 s! L" Y. k) n: Y/ _. E% k
4 k% U( K0 z7 D4 q想确定一下
$ `* |# b9 k4 U: ~- V7 e, k7 f谢谢!) S9 ^0 N) A4 B0 m1 S
|
|