|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序7 s+ ]3 j* C0 x6 D1 K" f' k/ @
其中有一段如下: X' b" R, p* N' k2 v( z; ^2 X' j' C
ask turtles with [ infected? = true ]
" `! P+ P1 G2 L+ L) b我原本以为这句会回传『所有』infected? = true 的 turtle
/ s. G0 k# P7 D0 U$ k) Y但看结果似乎不是这样。- W5 G1 z* \, x, q. f+ j& z
1 R; s I: u. B) Z8 d假设所有符合条件的有 5 笔% S$ V7 z# E9 H0 k- \2 q
有时候回传 1 笔,有时回传 3 笔,是不固定的) X( | |4 g' E
回头查语法定义
: U! c/ e4 l. K3 |with
3 a/ ~2 H* l4 g" ~) S+ Q$ ^) kagentset with [reporter]8 q$ Z# u7 C* L' Y" @5 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.0 k' f9 U. t; G) Q2 y: e( I3 f2 u) X" ^
它只说回传 agents satisfying the given condition
8 `8 c( G. e N是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? ! k4 G d: L# {4 u( R! w
' ?, Z/ F1 @3 g) g
想确定一下
6 g3 X% d4 j) g' _' `! W, [3 P谢谢!
, d1 l+ [* |* P- l |
|