|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序" {/ a8 i3 [3 i. P) d
其中有一段如下
' M) z; _4 d. L$ V3 vask turtles with [ infected? = true ] ( `/ T" r5 ?- u* v8 w( } X
我原本以为这句会回传『所有』infected? = true 的 turtle* [. a' c% ~$ h' \: c B
但看结果似乎不是这样。0 w& w( x+ `7 f" [
' u9 u7 g5 j0 ]: H& \假设所有符合条件的有 5 笔( x# [5 S* B* J1 T5 A3 b
有时候回传 1 笔,有时回传 3 笔,是不固定的
1 w8 H% [7 a' ^$ K& X8 K回头查语法定义; P. w: B/ d; j- B' g
with
( O! p7 h0 q7 w. R8 `& aagentset with [reporter]
" E2 o; i" Y( ]3 O' u# {, _$ F6 WTakes 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.
/ H1 r( J/ b5 n& ^) t: n2 q3 }) |它只说回传 agents satisfying the given condition5 \; Q ^2 P, K
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
' d ?: P* k8 D4 H6 S( g7 d
0 G0 o& h p3 ^1 e8 [想确定一下% H4 v& X0 N5 t7 q. q- k
谢谢!" a0 X0 b" \$ I) d$ r
|
|