|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序/ g$ o7 `) S4 F9 X7 q% o. I
其中有一段如下
P5 U4 \3 ]; u0 m0 ~ask turtles with [ infected? = true ] ! n- d% z5 R' i! w
我原本以为这句会回传『所有』infected? = true 的 turtle, a1 h1 a, z6 }" [% ?; i5 @: ~
但看结果似乎不是这样。
7 Q4 y' F6 ?! j/ H. U1 K3 n9 v6 ]2 ^2 ]4 Z6 P9 _ ~
假设所有符合条件的有 5 笔
3 j5 m! Q- \2 T7 o, k% a有时候回传 1 笔,有时回传 3 笔,是不固定的
- p H, R% }$ b4 s$ r回头查语法定义
/ D8 @/ ^, g( \( r: G' Awith
( n0 t9 d3 W. y. a1 ragentset with [reporter]. p! g9 Y7 @0 N1 \' v3 ~; 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.
% h* K2 {" ~! Y0 T; s它只说回传 agents satisfying the given condition# z2 K& s3 A, t B. y, i2 O6 o1 |
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? % ^3 b' e' g" |+ h& Y# H g
2 g- L2 H) W$ w1 Z0 E& ?3 r0 A! \想确定一下
' s3 O+ I1 o1 I2 d7 W谢谢!
! i [ @1 k5 E& o |
|