|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序. q" ~8 h2 @/ c2 H; n6 n5 w
其中有一段如下
' U4 O. Y! J' Z% S2 P+ `. Nask turtles with [ infected? = true ] # t( x$ q( h: N6 f; B) n4 n
我原本以为这句会回传『所有』infected? = true 的 turtle/ E- a$ c0 Q& U- l
但看结果似乎不是这样。4 K8 [6 J* T4 f3 G8 b' f
: s; d9 O. X& f6 t$ d. p9 F4 W假设所有符合条件的有 5 笔
( W$ t3 |8 x6 o- n: S9 s有时候回传 1 笔,有时回传 3 笔,是不固定的; c/ B% t( ^; ?0 `7 Y# o- a
回头查语法定义 I- A6 h0 a6 [9 o) _ S0 R5 q3 K
with
! b- K/ ]0 k; ]. H2 Zagentset with [reporter]
0 a6 S, z) [5 h; QTakes 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.9 [( L% c8 p0 l) U
它只说回传 agents satisfying the given condition9 k5 C% Y2 E0 n2 e4 W7 J) F0 R& O
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? ' k& D) D$ T, u' G# f8 W) p
" ` X& S) K4 W; I+ O想确定一下* h- V: a& A3 W8 [" s
谢谢!6 z5 b( g& {. R" ]
|
|