|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序0 g( i$ I- `/ J8 x, m5 b! i/ @, _# K
其中有一段如下" R" c3 h2 e4 T; U* I
ask turtles with [ infected? = true ] 3 |4 k5 c5 d* V* C( o, b
我原本以为这句会回传『所有』infected? = true 的 turtle& x9 x3 Q# ^2 C2 O" b+ k% P
但看结果似乎不是这样。
% r# D8 A+ u/ i. p& A/ O T# W0 [5 n# t0 K( `# d8 b
假设所有符合条件的有 5 笔; M4 K% _ z7 J" g7 M9 }, a
有时候回传 1 笔,有时回传 3 笔,是不固定的0 Y' h' a+ g3 t1 U; z
回头查语法定义- [& i9 D7 V* {0 ]! m+ u
with
9 N% A q8 H; Magentset with [reporter]
9 ^: ~( u+ F1 ~- e& tTakes 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 l. w0 K! z& Y$ F/ M它只说回传 agents satisfying the given condition
L4 i. m5 D% N7 ^+ U是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
: S) c) Z% w" k$ I3 }; J8 ]( d+ p6 O1 ]2 } g! Y% Z$ J
想确定一下8 _0 I+ B) @: P
谢谢!
# E9 p& p& t- L# D5 l# T9 g2 G |
|