|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序6 X( F5 i, J$ ~7 O
其中有一段如下
1 v7 D8 i7 p# M6 C7 Jask turtles with [ infected? = true ] - p, F0 ], p3 g! I. g# s) p
我原本以为这句会回传『所有』infected? = true 的 turtle) M' ]7 X9 i( \' d' B! u/ _
但看结果似乎不是这样。
: C% ^6 N0 _) }- P T c) p
. V3 d3 I5 K" R* k! [/ `假设所有符合条件的有 5 笔
j. G3 F& m, T( @: N+ A$ M有时候回传 1 笔,有时回传 3 笔,是不固定的
, {* I% Q0 c' C$ c回头查语法定义
7 H' d; ]# _" b3 Q1 z p ~3 P6 Fwith 9 g1 H* |# z5 ^$ d: w" x1 P
agentset with [reporter]
/ w3 V+ j g+ y% FTakes 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.
, u" J* s4 J9 L$ p' N4 R它只说回传 agents satisfying the given condition* N0 {5 b- I6 u% Q! L4 `7 [) s
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 5 c/ Y& L4 ~7 Z
+ F% Q; g, F6 y想确定一下
9 M2 E+ l2 m$ w1 K" @谢谢!
) T3 H+ W S4 a* j! h |
|