|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序, K! ~/ \) G2 f8 Q/ ^9 F9 }* ?& F( N
其中有一段如下
/ [. I1 |- `( xask turtles with [ infected? = true ] & z) y% e/ d5 y* M& |$ D. x
我原本以为这句会回传『所有』infected? = true 的 turtle5 q* J8 ^8 {. I i
但看结果似乎不是这样。
/ ]( C8 X+ f( V3 N/ G% r/ f" h3 A: g! c+ }7 u( m
假设所有符合条件的有 5 笔
+ q& W- Z8 }1 ~7 s- F9 G0 `有时候回传 1 笔,有时回传 3 笔,是不固定的5 R$ z& U& Q) Z. m$ x
回头查语法定义2 u' k, r3 K% X( h: \& f
with 3 s* q; N( Y% _" v' z7 _3 Z% N, O
agentset with [reporter]
# U) y9 `7 R A6 ?& ]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.
& @% P4 _. ^7 X+ W1 t! j它只说回传 agents satisfying the given condition
7 s+ G$ |. @+ k; u是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? & @/ _% [# M( G+ X, H J
& F: K, f, o3 |, a3 `2 s& `
想确定一下
6 F, M/ ~" C2 s" k4 W; ~谢谢!' W; @+ P/ S+ X7 v \+ F9 }1 o
|
|