|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
) ?; s/ `+ W- t其中有一段如下* e) l! o7 P. [) a' y
ask turtles with [ infected? = true ] ' h7 N1 C0 _: h
我原本以为这句会回传『所有』infected? = true 的 turtle6 A8 S z. N+ J9 x+ ~' h# ~% E
但看结果似乎不是这样。/ W! Q1 @& {8 b2 s* y9 {
6 v Z: S9 }( H" }9 ~+ T( b假设所有符合条件的有 5 笔8 B1 k0 B3 `8 f; W* }' r2 r
有时候回传 1 笔,有时回传 3 笔,是不固定的
. j1 ~4 L1 i8 y/ U- K回头查语法定义
3 z2 Y( x# h& | U3 O$ j f- k$ Bwith
/ i; }: C' b* f, r- d4 @agentset with [reporter]
0 ~5 V! |9 k9 p# w9 STakes 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.
$ o1 F5 }/ N- w& ~( G6 ]它只说回传 agents satisfying the given condition' |( w5 y5 @' X y+ s6 B
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
6 B1 v" R! X; n6 S1 g) E8 u( T0 p `' M
* L. z& ?4 Y% d$ C" a1 i3 \想确定一下; [( s# ~! R) ?) h
谢谢!
7 F* K. |4 t( S |
|