|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序. H' c5 G0 U( a
其中有一段如下
- F6 I+ r- [$ Qask turtles with [ infected? = true ] + I, F2 \9 b% p* U/ d
我原本以为这句会回传『所有』infected? = true 的 turtle
$ c5 D0 ~! Q. Y但看结果似乎不是这样。 I7 J( w# s/ k% r
. D6 h7 F) D% W2 s) X" Z8 C/ K, _假设所有符合条件的有 5 笔
% i& u/ j3 ?: d$ v% I有时候回传 1 笔,有时回传 3 笔,是不固定的/ p+ p7 x1 R) F4 T3 @( d# E& g
回头查语法定义: t; N4 N+ U& o" S( T' l$ J5 O
with ( c, l* ]( p4 a, U# S2 d% @
agentset with [reporter]! H9 B* G/ [2 [! J& i
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., J8 m; R1 t7 d9 O9 a3 }3 L
它只说回传 agents satisfying the given condition8 ]) J, p) E$ `' _# l
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? , d7 h$ i! d5 U5 i% X
5 q3 O! ?1 t+ F2 S8 p3 |想确定一下
: l' X# f7 S5 z: u谢谢!) d' m1 U) Q+ y. p' O0 r$ I( `& h
|
|