|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序" ^6 g- h5 t8 k; n
其中有一段如下
1 Y. z1 @- Y# g( D9 |ask turtles with [ infected? = true ]
9 Z& [* ^; V* U E4 Q+ c我原本以为这句会回传『所有』infected? = true 的 turtle' A: e( ^* f/ e: K# z
但看结果似乎不是这样。) r3 P# M2 p6 U% O6 W; k
. B y x1 ^3 o; H, L/ N* ~: t3 V
假设所有符合条件的有 5 笔
- Q. {$ D) R+ s- j有时候回传 1 笔,有时回传 3 笔,是不固定的: a4 c! Z8 `1 D9 h
回头查语法定义: d. u% q' E* D9 V, n5 r0 m! ?. I
with
5 r" c, F; |- T5 m) I9 kagentset with [reporter]7 e2 X. j( B8 w: ] {* y2 C" t
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.
' n$ \- U" ~+ y7 W它只说回传 agents satisfying the given condition2 D, A+ f( V! u
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
2 P/ c) e$ p# R- ?" j/ [, Z' w% v1 T8 v5 D0 I
想确定一下9 _2 P# d, h; r( _
谢谢!
, d6 b, ?- h6 i" L: v! h! y- @: R |
|