|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序1 c, X6 c& H' d1 t
其中有一段如下
/ t- K0 H, f/ v& J) Mask turtles with [ infected? = true ] # N( M+ R G& T, q- P A" ] e9 q& [
我原本以为这句会回传『所有』infected? = true 的 turtle
1 a1 J x( U2 m7 R @) {8 I- I但看结果似乎不是这样。
0 @) T5 E% ^; X1 f( K! V' y( w8 _# ^1 U; l7 ], G9 I# d
假设所有符合条件的有 5 笔
% P& \9 b& @/ I有时候回传 1 笔,有时回传 3 笔,是不固定的
6 ^- L+ ^# c2 J回头查语法定义- C* Y6 ]) x& K, F Y C- C
with . \. u$ a; A* d1 H7 f4 B8 T
agentset with [reporter]" Y. _ a8 d+ x% v( u& x0 i
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.' j/ h6 h2 }5 P# R6 W3 T# g
它只说回传 agents satisfying the given condition
9 M0 [# z- K, p& v+ L是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
8 U5 b0 D& M4 g: s3 Y# l" t6 d
5 ^* c5 y$ D" y, o$ D想确定一下
; _% `9 R3 D; |# ?: z" D$ J谢谢!
: r# B) L2 c) q/ R3 @" k4 K |
|