|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序, z4 I$ S5 k) H9 o( \' T/ \
其中有一段如下1 h3 w6 |- A( X
ask turtles with [ infected? = true ] : m. t4 X8 | ~) O. I+ m# j7 `: i
我原本以为这句会回传『所有』infected? = true 的 turtle0 x! m8 X) c2 f: H0 G$ y9 J
但看结果似乎不是这样。9 y8 s0 d) i' Z( b. W
- {" A3 X! Z. a9 }. I
假设所有符合条件的有 5 笔, A7 ]0 t5 p, E: o& c
有时候回传 1 笔,有时回传 3 笔,是不固定的. ~1 v- z% k1 W) @; M& c6 n
回头查语法定义
4 ?- c; G' Q7 owith $ @1 D F1 e* D* D. w, l9 a" ]
agentset with [reporter], s: u* }' Q r y* \2 j
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.
4 P- j/ O2 ^! G0 u: R5 H3 I' C; R- K5 A0 f它只说回传 agents satisfying the given condition5 D9 D. H! w3 H7 c
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
g1 |+ Y/ b$ _( A: u" Q- r" }! `3 t$ |
想确定一下+ G! W' R. M3 g2 _! k
谢谢!
0 }2 f" ]$ z1 p2 e |
|