|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序3 R7 @3 z( D* A3 ]& X- l
其中有一段如下
, S) c: _" r6 d+ Nask turtles with [ infected? = true ]
. `! ]. m4 Z1 e, t p3 w我原本以为这句会回传『所有』infected? = true 的 turtle9 B, f' `% |' a& e& {( T% |
但看结果似乎不是这样。
g. A% M6 `# ^% O9 k7 I
( P7 N0 n$ q+ N) N7 T/ Z) C8 v假设所有符合条件的有 5 笔+ i0 Y4 l$ e0 K y; |. S4 L
有时候回传 1 笔,有时回传 3 笔,是不固定的
- U$ W! A8 Q! ], a回头查语法定义
! }) L) o, i! ~/ [4 Nwith
+ D) z( X* Y2 _+ \, oagentset with [reporter]
5 @) E7 W" j" }" O' Z/ bTakes 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.5 E1 w7 m4 ]$ x5 a' O3 l
它只说回传 agents satisfying the given condition, @5 c( E7 I% X
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 7 ], g; ?- X" u y
) [8 ?& J( {0 K) m% i
想确定一下
2 z& v ]' u. l谢谢!
8 N+ T2 [. T, {8 c9 C. D |
|