|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序4 R& B4 x5 n0 ^& t7 q6 K
其中有一段如下
/ J, h. q% [4 j2 r) U% o7 xask turtles with [ infected? = true ] , c: f5 }6 p2 ^6 _5 ?* X0 |) y9 f) Y! ~
我原本以为这句会回传『所有』infected? = true 的 turtle
: w* V8 ?$ U0 k$ w3 j但看结果似乎不是这样。. W# i& d- g2 W, h) z& j+ w0 d2 V$ d
0 ?7 y+ [/ O/ A
假设所有符合条件的有 5 笔
2 G( i2 U% m; }6 ~! U有时候回传 1 笔,有时回传 3 笔,是不固定的
' B- N( f8 J' J! b* ?: M回头查语法定义
4 q' e3 o; e, hwith + j, J g+ R) W, E' P( f
agentset with [reporter]. D+ ?# w: M$ W8 F
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.3 Y9 e3 A. D6 x( n
它只说回传 agents satisfying the given condition
, [2 t: I: [: [9 ^% m L是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
1 d; V. Z, C) q6 F3 p& r! ]5 T
' l/ B; g3 z5 h# @想确定一下
5 F: T& M0 Q2 K0 v谢谢!0 D [( {7 q! s* V. p! N% }
|
|