|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序" r ?; X# y8 V G" [' t. s
其中有一段如下
2 I& s! _, c S9 u! f6 P5 wask turtles with [ infected? = true ]
' z; m& ~# _0 Q" i. G1 N我原本以为这句会回传『所有』infected? = true 的 turtle1 ?! Q9 {3 @0 s4 E
但看结果似乎不是这样。- A4 c/ S+ [ H5 H2 b3 k& g0 H
( M" ]2 O' O# w: j假设所有符合条件的有 5 笔3 O7 R) z `' q; `, I; p; d. L3 w. `- ^
有时候回传 1 笔,有时回传 3 笔,是不固定的' r( W6 \- e2 `5 f
回头查语法定义& ?/ z/ f0 Y o: K2 y! W" r; A
with
5 ?( l; D' a5 F" |agentset with [reporter]# S8 ^0 `3 _3 Q7 X6 u% l
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.
( c( c" @. k b, o# l# F它只说回传 agents satisfying the given condition; ~6 Y4 R) T: _4 Y0 B
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 2 X' x: z) I, @
6 V, T1 S" F \! Y, x, |, U
想确定一下+ f" G' q2 a9 W1 b/ g7 O) M' n
谢谢!
# P# Q' L# p9 ?* j9 w$ c |
|