|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序: w! ~) r, L: H& L0 J+ D$ ]+ m
其中有一段如下
% Y3 Y. o& n3 E' f4 Sask turtles with [ infected? = true ]
* _5 r8 O- ~4 X; \我原本以为这句会回传『所有』infected? = true 的 turtle
6 Z5 S+ J% x1 X4 U8 e但看结果似乎不是这样。 K5 i( q2 K. `0 o6 C3 B
4 @! `( r* z, R* Q6 l. _假设所有符合条件的有 5 笔
4 C. k/ M4 [7 V) k n' K有时候回传 1 笔,有时回传 3 笔,是不固定的
- R$ f+ t' j7 \1 U5 J' l回头查语法定义
$ _2 `. Z) J' k- g8 k: U3 f! T% ?with / m& n7 m4 H) r
agentset with [reporter]$ \. U3 v$ O' d1 C6 J* @: s
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.
" Z' Y( ~) a6 W& f- a+ N! D它只说回传 agents satisfying the given condition
: `! a5 E; R1 U是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
@& h+ J4 [- q
% `! _+ x3 Z4 P; h; D想确定一下
) s, @ u: F6 \; q% l7 `- N谢谢!
& }! J2 K) x( C6 Y; s+ j2 E |
|