|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序: `' B4 R; V( G/ Q; w# D
其中有一段如下
+ C' M2 ~9 ?6 ~/ |* ~: @2 Hask turtles with [ infected? = true ]
7 H: f9 {4 ^2 D& V我原本以为这句会回传『所有』infected? = true 的 turtle4 Y: Y+ T4 M' U$ D- w6 {
但看结果似乎不是这样。- ]' O. P3 ~9 q4 N
" i: U: g3 ]+ u8 d/ R5 K5 R: k! q. y2 |
假设所有符合条件的有 5 笔
+ L, d1 w! u3 S; m2 F( ^! }有时候回传 1 笔,有时回传 3 笔,是不固定的
: U4 z: b: I1 k) S d' P回头查语法定义9 d; _( {4 p2 G" H( ^
with
, T$ i1 P$ V$ _4 s7 X# Iagentset with [reporter] G4 p: }$ w7 y4 E, N9 D j+ J
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.
1 \2 \ x0 ~" e$ y它只说回传 agents satisfying the given condition% u2 Y5 I' n" V1 K0 J. u
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? ' d/ o. s1 g9 U) K
" k5 e5 t4 l/ a9 b5 J$ @想确定一下, f, }" l- Y/ X, P7 Q
谢谢!. m' T6 p4 U l# h5 x$ P9 `1 }
|
|