|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序1 I a% H& ^+ V8 z% G4 |' X5 Q
其中有一段如下
0 j* W( S: p* F2 ]$ @& X* mask turtles with [ infected? = true ] : C3 G4 b2 D4 u
我原本以为这句会回传『所有』infected? = true 的 turtle
& M: l7 O* ~/ B* {6 ~6 P- `2 A但看结果似乎不是这样。9 v& R' U1 ]1 ~$ p) Y
+ M" ?7 p$ m( B3 b+ D$ P
假设所有符合条件的有 5 笔0 R8 g& N( u6 h# T5 x
有时候回传 1 笔,有时回传 3 笔,是不固定的# f3 V5 k2 _& c8 \$ v
回头查语法定义' @; v+ l* D- J* o; p( m
with : R" k. i/ L3 M
agentset with [reporter]' |+ z. P5 t8 u( r, Y1 Z8 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.
5 g- s% S0 f& a# l它只说回传 agents satisfying the given condition9 ~& ~ y8 a; Q, x* e* G
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
% b7 V% a/ h& q: f& M
- y$ [* _, K8 D$ U想确定一下; G5 w f* W, L- f
谢谢!8 G. S& N' M4 a4 f
|
|