|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
* h: C$ S$ A: v( C- l2 o其中有一段如下
' t; E0 m3 Q) w& @% vask turtles with [ infected? = true ] : w$ t [* d, S) u
我原本以为这句会回传『所有』infected? = true 的 turtle
$ }# H* v& J, U3 v7 Y4 E' g" J8 \, d但看结果似乎不是这样。9 [6 y9 w; |; E9 G& {
3 B6 K# a) n2 M
假设所有符合条件的有 5 笔
/ D! p# W/ M0 h/ s1 l) I1 h+ w有时候回传 1 笔,有时回传 3 笔,是不固定的$ k5 w& P7 A3 j6 O- c
回头查语法定义- Y7 B( a# r. p* X- J9 h
with
+ t2 ~' W( U: G Nagentset with [reporter]
' t& D, ?0 K+ F) _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. r( z" D8 u* L3 Z' Z
它只说回传 agents satisfying the given condition }: e$ j7 j3 H; K- O! ^
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 5 g+ ~, Q- k. `
- X3 r& M- L1 W0 X2 [
想确定一下
3 m! U2 o* B/ W谢谢!* L j& N$ g9 ?8 M9 x: [, f
|
|