|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序/ v, S8 E4 d& V, X1 k
其中有一段如下
) |& [. R* S- `* ]ask turtles with [ infected? = true ] ) m, r2 N3 ]0 S1 H' ?
我原本以为这句会回传『所有』infected? = true 的 turtle/ w* U3 N7 ^8 j0 s5 t. N
但看结果似乎不是这样。! Z+ K$ D& h/ }* h) i @7 Y' e [
% t: H/ g( z5 t5 s假设所有符合条件的有 5 笔8 D6 E+ I" A/ `# I. m+ M, i3 ^; x S
有时候回传 1 笔,有时回传 3 笔,是不固定的4 B" y$ X4 V# [7 U% g7 `
回头查语法定义3 U) }0 f0 ~$ o2 h9 _
with
. O& ^% z& u3 m: D; Z/ aagentset with [reporter]
- R2 r; q9 o- p dTakes 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.
' Z+ U1 m0 P3 F它只说回传 agents satisfying the given condition1 f' a. B9 q! \8 L, J
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
* R+ C% h8 l+ U. G+ j5 _# V( c1 l8 t- Q9 y; R Y( a
想确定一下# x8 u' N! b1 m$ _; G
谢谢!( Z* A" g# P6 c6 A# h& H+ H
|
|