|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序9 d' q" p$ D' X9 E0 B7 A. I
其中有一段如下
2 E! `1 O2 u) [ o) w [ask turtles with [ infected? = true ]
d0 J8 ]0 ^) Y0 D" J, k: C, Q+ \我原本以为这句会回传『所有』infected? = true 的 turtle
8 x! U, X. X7 e2 H8 e/ e但看结果似乎不是这样。
' `" x, ]/ }. i$ K. P u- a$ I2 A. H0 n
假设所有符合条件的有 5 笔
" l m& J" ^- q- v' a8 ~有时候回传 1 笔,有时回传 3 笔,是不固定的+ {* C# R* \9 O5 X+ u: F
回头查语法定义. F7 F R, }, w
with 5 |" m5 a' }7 z5 l; L; L' J
agentset with [reporter]0 M- \1 [ u. z h, G+ f9 a
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.
" B% V* _: x0 C9 k# M- D: }它只说回传 agents satisfying the given condition; `' g, b, ]) T* D, Q+ r
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
0 }+ [: p' d8 S
1 u, q- m5 m1 a# g想确定一下
7 \+ c- p6 t$ q3 q谢谢!
, d2 D, e$ M" F# Y3 a* v' l+ M |
|