|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
2 _( _$ l5 X; C3 V- m, M* v. ]其中有一段如下
3 \5 c% q8 w6 Q3 `. Bask turtles with [ infected? = true ] ' p E8 D$ `6 k) r6 ?
我原本以为这句会回传『所有』infected? = true 的 turtle
; V2 k3 U1 }2 I, V% `- q5 v但看结果似乎不是这样。
7 y; z3 N7 H8 w5 g: P T s/ o7 P6 a: d ^+ T' q2 o
假设所有符合条件的有 5 笔
! T% ?. Q' \/ Q" S7 ~$ f) p有时候回传 1 笔,有时回传 3 笔,是不固定的
' U1 `5 P& J7 [8 H+ d回头查语法定义; _+ v/ Q0 ?! p/ V# D" c
with # u, s0 i7 ~7 }6 _: j
agentset with [reporter]- w5 }( X6 y3 O, Z9 x
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.7 ]; {7 r% S3 O; {* s4 O
它只说回传 agents satisfying the given condition
, Q# w, g2 L' K1 E6 w' [3 j% @是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
* H1 ~( Z- Z/ l7 X1 E6 y+ b, @3 N. J. L4 _; ^# a7 p
想确定一下
! E3 r s0 j8 q( {( o0 \谢谢!
! @9 p* {1 t/ y" Y |
|