|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
- u& j) c% W4 y3 k其中有一段如下! C& ~( k) N& }1 w& X
ask turtles with [ infected? = true ] * }, n$ \3 C& H+ v9 `7 B
我原本以为这句会回传『所有』infected? = true 的 turtle/ v1 I% p% X5 I7 H* J$ M
但看结果似乎不是这样。
. L" T. y Q q7 Q: T2 f) @7 K% j8 {) y! c% r$ o
假设所有符合条件的有 5 笔
2 C7 U6 r. l! N' }有时候回传 1 笔,有时回传 3 笔,是不固定的
7 m0 |% p0 _$ A回头查语法定义
( @+ K9 _ F4 I6 N0 Y( j+ Kwith
4 g! j3 g: b% h3 Fagentset with [reporter]7 I& T# f2 b0 e/ \
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./ m3 Y, ?# w! U! x, I
它只说回传 agents satisfying the given condition
) N- g$ G3 x* J是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? ! J7 Q3 p5 ^3 W. X" @- O ?* G
/ o+ W( L5 u' q! g
想确定一下, u" Y) W. W, a7 V, s
谢谢!# H3 Q) I. a* z
|
|