|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序& `. r" e$ n: v: B6 X1 \& K; j
其中有一段如下
4 S- ?7 p! o7 V2 |ask turtles with [ infected? = true ] 4 j; @ y, ~. ]4 J
我原本以为这句会回传『所有』infected? = true 的 turtle
) ~& d& I2 R i" I但看结果似乎不是这样。
- J! w/ S+ E B3 @3 q; V# L q# _' G
假设所有符合条件的有 5 笔$ Q0 u6 ?7 R3 f2 b- v
有时候回传 1 笔,有时回传 3 笔,是不固定的
+ B A/ _7 ^0 K" i/ }1 t' h5 l/ k回头查语法定义+ A' ]5 t3 ?. y9 k( }! b1 V( m
with
7 e4 C! O0 _9 c, }; @3 pagentset with [reporter]
7 F# D& c: T% k7 I3 I8 Y; ZTakes 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. P$ V t" M2 P' Q- }* Z2 Z% F
它只说回传 agents satisfying the given condition5 A) j* I+ s, K
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
9 `/ _: W* x7 {4 k$ C0 W% n4 b2 D7 s% m& l$ z: H. b* q, S; ?& R
想确定一下
/ |1 a3 v% _4 n谢谢!6 o: g; Y. G# \6 T
|
|