|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序6 K7 z! w9 I& ~ h5 c" i! r& E! j7 P
其中有一段如下
) O U. G. H1 ?/ cask turtles with [ infected? = true ]
+ |* R8 T& _& Y W% i' f我原本以为这句会回传『所有』infected? = true 的 turtle
6 U: T" S% g, O, F: `; V2 t* q, J5 t但看结果似乎不是这样。
$ D4 m# H$ a W, B9 F7 {: M* K; |. n" B
假设所有符合条件的有 5 笔
% W6 h4 V# N+ _. k4 U( I有时候回传 1 笔,有时回传 3 笔,是不固定的
. ?- m! j8 F X. E2 v3 W5 ?回头查语法定义 C& E$ X2 i0 B J
with % J y" [( a+ p- q u
agentset with [reporter]9 ~ U, N$ X% o( T
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.
! Q2 S7 r4 W8 C它只说回传 agents satisfying the given condition! w2 }" w4 ~- x- L4 q
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
I k4 W( S, q6 y0 \" R% O$ p4 l+ G5 ~5 Z
想确定一下
+ e) R- z# U! B谢谢!
3 D2 B: a8 J1 D6 q! e7 m. N8 O. E |
|