|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
% | s. E7 m. |* n" N其中有一段如下
7 W" R7 `2 Y# R) R E7 Yask turtles with [ infected? = true ]
, r8 W* A1 M& ]7 t我原本以为这句会回传『所有』infected? = true 的 turtle
- m( j7 x& t# p" G0 X( u但看结果似乎不是这样。+ R( A8 A; Z+ J1 K' z
- O% z: E) M8 `
假设所有符合条件的有 5 笔- d. G2 V' ^+ U
有时候回传 1 笔,有时回传 3 笔,是不固定的
# d6 @$ S# Y8 c i* M回头查语法定义# _* ?( @7 F# x( ~
with % ]% k; t1 D2 E" r5 `" x# ^
agentset with [reporter]9 g5 ?0 m7 G0 K
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.
- H3 i' T4 }6 d: j& z/ I- N它只说回传 agents satisfying the given condition' {6 o0 j ?3 W
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 6 p4 v$ V( R4 W6 u3 f8 ^
( N1 _; T7 }2 j$ c( B* T想确定一下
" Q1 o8 c% C- F0 u+ o: e/ l% E5 G谢谢!
" r4 u% S. q+ f( i8 I' o |
|