|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序2 U1 ~3 \$ i. e, l/ J
其中有一段如下
! S, Z4 [ C2 b0 u% L: B$ _( U: aask turtles with [ infected? = true ]
3 }) I3 G; c& a. |4 p/ d" M我原本以为这句会回传『所有』infected? = true 的 turtle
3 c) j, i( u1 r% ] V1 y+ @但看结果似乎不是这样。
* f4 P% n7 }4 u7 d7 i4 r0 Y2 x9 S5 e; r
假设所有符合条件的有 5 笔- z4 L, P, E1 |( [7 ]
有时候回传 1 笔,有时回传 3 笔,是不固定的* x6 @+ s( U" z v, c: U0 W
回头查语法定义
3 I% }# q* ?( h5 W- }with 6 p" p5 r% M+ d K
agentset with [reporter]
7 M) y+ B( C. @1 u3 `+ VTakes 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.
+ g; V+ D- F; `! O它只说回传 agents satisfying the given condition
5 B) A9 M* o- {5 q是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? * G* X3 |% F; ~! i
6 f: U! d P' _9 g
想确定一下
" C% |2 f& g% i1 I* r- u* I谢谢!
& E% V0 |" r8 u/ ]9 e |
|