|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
. y% \3 o/ X8 I其中有一段如下) h& H$ _/ p8 A, o! x% J* f
ask turtles with [ infected? = true ] + p% \6 }4 R8 x5 y: z
我原本以为这句会回传『所有』infected? = true 的 turtle
( Z6 i, I" k1 |% `, r; B& ?但看结果似乎不是这样。
9 P% h& E$ u5 R; E E8 \3 w
' F6 _% C3 ], A! a) t- p! v& \假设所有符合条件的有 5 笔& j& f9 o; I1 z- ^7 `
有时候回传 1 笔,有时回传 3 笔,是不固定的- t# b% d9 p+ n( ]1 z6 m* p% K
回头查语法定义
! \, G& P# o& i% b7 v- Xwith
7 [% b8 v' V) s. p, cagentset with [reporter]5 H$ L" O1 W. n6 C' n" `
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.
5 P5 B* O- b/ H$ I* Q5 ], v它只说回传 agents satisfying the given condition
, L( o/ N9 H2 s* v是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? ' Y2 A8 s* E1 B$ r- `/ A# k
' W" O( V, N6 T& _! [% B0 r想确定一下
2 a1 V% w% W3 X' B K谢谢!# O) _8 `: X- C7 S o/ W
|
|