|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序" J% M( S2 V" c6 S. ?) X
其中有一段如下
, [3 Q g; q' Z/ I3 t/ eask turtles with [ infected? = true ] * _( A; f, v0 x3 F, C+ ~
我原本以为这句会回传『所有』infected? = true 的 turtle
5 ]& b; G+ b/ ]& h& L, x! k3 e3 n但看结果似乎不是这样。+ F2 n- Z6 f5 { y+ n: k9 R& Y
( h2 n- g4 W+ n3 k% F1 T: [0 T" [, ?假设所有符合条件的有 5 笔5 k0 n* U# a9 T1 M- k2 f5 D: _) X$ U
有时候回传 1 笔,有时回传 3 笔,是不固定的8 l* q& [8 ?% I4 I5 X3 _0 k2 B
回头查语法定义* Y8 S+ i& r) F+ b5 y; @; z
with 5 O& V7 V4 |, I! ~( t& v- r, H
agentset with [reporter]
/ ^4 t5 j# Z3 k' }- R1 OTakes 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.
4 Q# Z( b% T. V. p9 b7 x它只说回传 agents satisfying the given condition( s8 k3 N" X0 M. p0 C
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? . p; a& a: a/ K% g
& N8 J- D* J1 b. o' W" h/ w想确定一下: ^, J) G6 a3 ~2 Y
谢谢!& G c6 Y7 \7 K2 {$ L
|
|