|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
K$ k( j. ~ {4 q e" i其中有一段如下
1 F- b1 x, `: Q5 Z( _1 _ask turtles with [ infected? = true ]
; `* l$ M- A! c* I# O我原本以为这句会回传『所有』infected? = true 的 turtle3 X( F% o! `( x2 r! Q7 K! E
但看结果似乎不是这样。
; u5 r( g6 C+ ^& \2 P7 {; D. I0 i# D
假设所有符合条件的有 5 笔
. k: D8 R8 o- _0 \有时候回传 1 笔,有时回传 3 笔,是不固定的
7 S |" a) R3 O$ u* ~, Z9 ?: \/ S回头查语法定义3 b5 W, Z9 S/ s c
with
# \$ A0 x4 P7 S* Y. U, V; @agentset with [reporter]! Z# d; J1 y6 P K, h- p7 ]5 ? ]
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.
! }0 n1 \$ F, y它只说回传 agents satisfying the given condition: L+ {8 y2 U( z7 j" N# r
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 2 |2 w/ z% z: w; i6 |# M
7 S; z I0 k7 b* x6 R想确定一下
! F' g' ]3 M* {0 v+ {谢谢!* C$ \& T5 T* @, g+ I/ p
|
|