|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序# E6 r7 p: w9 o+ }+ B
其中有一段如下
( `# N' c& \/ z. @- I9 J: g' R! mask turtles with [ infected? = true ] ( i" b9 D9 {+ q) J, h# G
我原本以为这句会回传『所有』infected? = true 的 turtle
3 |( K0 u# t8 H: T4 w& @但看结果似乎不是这样。9 q: E3 ]0 }: v0 h
# J, s" ~1 j8 c* p* m2 n$ ?假设所有符合条件的有 5 笔. Q+ ^+ X; f. ]+ g0 h/ q
有时候回传 1 笔,有时回传 3 笔,是不固定的0 a& v+ P# a2 |- ]
回头查语法定义" x7 w9 p, _! s3 x
with
6 V' c; k j, e' w- F4 Yagentset with [reporter]* w+ C, y+ a1 |0 q j
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.
: j, W3 _# q/ u4 X! o9 h它只说回传 agents satisfying the given condition3 V: }$ o/ s# S6 R% W
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? + Y L8 S5 ^ k( I( c& F
+ @! I( P9 o* Q9 w
想确定一下
; B1 g2 u8 k3 x5 c1 k谢谢!1 y" |6 t+ O' i! j6 G0 k1 j5 }
|
|