|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序: R+ G: W8 P* Y0 X6 }
其中有一段如下
, z# k1 K3 U: |9 O* @ask turtles with [ infected? = true ] : b6 |7 l. I5 H" y) V
我原本以为这句会回传『所有』infected? = true 的 turtle
. w5 Y1 e) I0 {' [但看结果似乎不是这样。5 Z# W6 M6 P+ s2 f
) y& t6 @6 ]8 t假设所有符合条件的有 5 笔) l/ _4 Q2 {0 q" c
有时候回传 1 笔,有时回传 3 笔,是不固定的
/ y3 |7 x' K' |回头查语法定义7 k! [ l- X0 a8 n" W9 t2 Q5 M
with
' ^$ D; U* T1 }% B9 Sagentset with [reporter]# m; F$ G- c0 Z6 F( I* X c" S* \/ @
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.( K, d- K, G% \3 Z. }" x8 r
它只说回传 agents satisfying the given condition
( U( c4 W' i% U# B R* q是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
& x$ z# }7 y8 D; S, a1 a4 x. W) v4 R# ~) D/ i" s' D- \& x
想确定一下0 F3 m4 K/ N0 Y4 i- _$ n/ O
谢谢!1 {% i! \% i4 b: X& }
|
|