|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序" M6 Q8 N( G" ?9 W/ o' r
其中有一段如下. q( R. T1 {3 P2 z2 d& }
ask turtles with [ infected? = true ] ' z! s0 h ]9 n6 f# @% E
我原本以为这句会回传『所有』infected? = true 的 turtle
' w1 Q- q {" x& a但看结果似乎不是这样。
: R; Z; w. T# `+ G3 Y- w8 V
5 |, J; h& r$ h% h假设所有符合条件的有 5 笔
; E; L+ J' t2 p8 }有时候回传 1 笔,有时回传 3 笔,是不固定的# a4 S; D |7 W' f7 i
回头查语法定义
, w4 F+ q# J9 ^9 D u+ \+ F# |. vwith
6 s* J' j& L6 D/ B: ]" n& C5 e/ vagentset with [reporter]
. f. K$ u$ _6 H) }% }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.
3 C. c2 O: J+ z9 J# |它只说回传 agents satisfying the given condition$ z5 b. h8 }0 W [
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
& Q: n4 N) O+ i3 X- F% D$ w% S5 M' ~, b1 h: O" u2 B4 j
想确定一下9 @! M l0 ^- h7 r
谢谢!
/ L4 _. R7 l4 t: `8 I |
|