|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
5 c0 J0 J& c3 D. t其中有一段如下 S5 b* y7 J" e# ]
ask turtles with [ infected? = true ]
4 B: q! Q/ J ]1 U我原本以为这句会回传『所有』infected? = true 的 turtle
8 Q2 Y _! \& {8 M; D/ k1 J但看结果似乎不是这样。
. E8 k3 X6 }" w1 s5 \5 q0 j4 X, ?: [, R. I" F) k
假设所有符合条件的有 5 笔
! c5 |# S6 T) X有时候回传 1 笔,有时回传 3 笔,是不固定的/ \/ p& c% a& _; \: r4 u3 {9 G
回头查语法定义) Z1 N" |# F7 r. g
with & ~: F9 A5 T; O
agentset with [reporter]
. j. f5 b+ z8 q6 d8 WTakes 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.
6 H; ?( L% e! ~% ?# O- b1 G4 Q6 v5 `它只说回传 agents satisfying the given condition. ]8 O) F* F2 \9 Q, N+ X
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
) L9 ?, w( e1 e% G( v" x- ?- m3 M8 @" B4 A' X9 d. g5 ?
想确定一下, D3 N1 R! v! i" A& o
谢谢!1 r; l# `% z3 `# k9 O' I' f! }* i
|
|