|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序6 V' ]$ v7 H$ F0 l) I1 i( _) T
其中有一段如下
, j# V7 _8 A( C& N% J% o' hask turtles with [ infected? = true ]
5 {8 i. Z0 q5 P- f我原本以为这句会回传『所有』infected? = true 的 turtle2 x: h( [3 c9 J; ?$ z8 ^ _
但看结果似乎不是这样。
Q0 H( n: g" E& k$ | m' k- D" { U: {( \
假设所有符合条件的有 5 笔! Y1 J% S. H. J% [2 C; t" ]% t
有时候回传 1 笔,有时回传 3 笔,是不固定的& d" x1 p2 O8 k1 h5 F7 U) Z) J
回头查语法定义
K4 h' S& ?9 |% `: H; Pwith ; e8 q3 Q8 b5 u" }$ R& U1 X
agentset with [reporter]) c7 c6 E# u4 P7 m! o8 Z) ]5 B
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.
9 }& r& k% ]! l {: s! v1 X" C/ r它只说回传 agents satisfying the given condition
+ _+ t5 v9 L% _% X- {/ p0 B# Y; B- l是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
8 O7 q- R& Q: ~0 I& d9 o F# h) c% q. m/ L6 U( c+ j: @
想确定一下5 Q0 F# d, Y8 U
谢谢!4 R4 n+ O8 w1 z2 I1 e
|
|