|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
8 y. B! [! \* t) R0 _" S其中有一段如下, f; @3 p( E' f1 k7 w# o/ Y {7 K4 C6 a
ask turtles with [ infected? = true ]
: C) X+ A& [ L2 g我原本以为这句会回传『所有』infected? = true 的 turtle
% T' s, E* i5 H* L& z5 ?: f3 z1 a但看结果似乎不是这样。
! y$ K3 W, v3 [9 C
& p3 U( u+ P; J& e' x' H假设所有符合条件的有 5 笔. G$ Z, h9 W: Q2 R
有时候回传 1 笔,有时回传 3 笔,是不固定的
# g+ ^, Y# L3 H$ Q; r9 z- I4 R回头查语法定义
0 W7 G3 Q$ r1 X& e/ W+ O/ lwith
& k0 J- n6 P! q7 Yagentset with [reporter]) D/ E s: ?2 B1 `/ `" O5 w2 @
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.
( U+ Z9 c* Z, Q/ k它只说回传 agents satisfying the given condition3 n5 w2 N2 Y& ?* w |9 b
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? % r5 f! M2 e2 v$ [$ o1 h
/ p; x0 Y, _' b _. o5 q2 v: N想确定一下
. \( J/ \- W" W& i$ D6 ~谢谢!
7 x0 ]2 D0 D' f6 b; f1 z0 ] |
|