|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序9 G% w) z% _& F9 E) }# {
其中有一段如下) }2 F* w$ v$ G: y( V) U5 k, F7 E
ask turtles with [ infected? = true ] 3 z# H$ F8 y1 J0 A" L
我原本以为这句会回传『所有』infected? = true 的 turtle" W$ V' j6 ~4 z9 |% j8 U
但看结果似乎不是这样。 _7 S; E! U# b2 P* G
7 B; i7 w9 J! Z7 Q+ Y
假设所有符合条件的有 5 笔* v+ P* F8 G/ o$ F* ~, x
有时候回传 1 笔,有时回传 3 笔,是不固定的
% R8 l8 L" P7 o回头查语法定义
7 |3 P2 r; \% U8 jwith
# O, a: R$ k2 F9 g' ?! Oagentset with [reporter]
. j7 z0 I6 n# o9 f6 GTakes 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.
5 m; f( @" y) I- @3 t它只说回传 agents satisfying the given condition0 V. S: J! T( j9 p7 J
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
# L+ ]# c) d! @( d3 T
6 K- h& q& `3 {想确定一下! i$ d% v W& k1 S
谢谢!* Y& z8 m6 e9 I
|
|