|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
0 J2 G& f2 t4 w7 ]. G6 W5 O5 c$ f其中有一段如下
+ m# R: A0 K# l4 d1 \/ O$ Sask turtles with [ infected? = true ] $ B8 E1 H3 ~6 J" b/ r$ p1 P+ W0 `, J
我原本以为这句会回传『所有』infected? = true 的 turtle
' Y4 F3 f! u9 {1 \$ s6 Z2 }- r D, N但看结果似乎不是这样。
+ o4 [4 J& m; P, f4 `% H L, E m; M! d6 G$ N" L! S
假设所有符合条件的有 5 笔% ?* w0 o4 P% V) G- H) n) [
有时候回传 1 笔,有时回传 3 笔,是不固定的
Z9 \2 n" `2 {# O5 u- w$ m回头查语法定义+ _' c$ z( M, Q! ?0 x$ h
with 8 S) [% a4 t& L r' ?" J* [7 v" Q
agentset with [reporter]
q! m' m1 c+ y0 S. o( dTakes 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.% R1 }' R2 C- v& |) @1 n8 L. Z
它只说回传 agents satisfying the given condition- ?" o- p! c# u$ s8 I8 i
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
: P+ Q% ~: F, v5 x
& Q4 `* Y$ u9 O( {5 i想确定一下* n; M2 a. G# U/ _ Q x' w7 X6 K
谢谢!" O4 M8 j2 b5 e0 N. e9 x5 `
|
|