|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序9 B k3 w- p) t2 A. Q
其中有一段如下
: E- j7 {. G0 z0 Wask turtles with [ infected? = true ] 9 y- I- b! k& G* K3 @5 F5 B
我原本以为这句会回传『所有』infected? = true 的 turtle
9 i. a ~$ h R3 E但看结果似乎不是这样。
; p! T( }0 x# r* D- E$ z5 p+ }) b) _
. J' x5 `$ R0 e& q# m假设所有符合条件的有 5 笔
2 z0 J+ C5 G+ {, E; T* c7 q! X9 N有时候回传 1 笔,有时回传 3 笔,是不固定的7 |. `. g7 m2 u" Y1 T
回头查语法定义% }, j+ f3 b) Y2 C. i
with
. A& ~7 @" n ?* h: _3 |! nagentset with [reporter]
# G5 x) t6 g/ Y: {8 ^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." W. q% j, g; d" X4 K, U7 _1 ]9 c
它只说回传 agents satisfying the given condition
' _" y- E" E3 m! T4 a+ A是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
+ L% J4 y" U" q; R3 g# D4 V5 E- S6 q! N" B3 r' ]
想确定一下" H3 M, {9 j# D( m# X' f2 F' E
谢谢!) N5 a2 _; o- ?6 L! [0 [/ E
|
|