|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
5 X5 q! \( F8 }. `其中有一段如下
1 u, i8 _% ~3 @# Aask turtles with [ infected? = true ] + _& i9 c4 j S% Q/ g
我原本以为这句会回传『所有』infected? = true 的 turtle
' S4 ?8 J) m1 ^8 c9 v) I但看结果似乎不是这样。
* {5 r- G+ _8 q8 Y6 _1 {
+ H" s) m; L% P6 ?假设所有符合条件的有 5 笔# f% L% d. l1 `4 v' ?& @! u
有时候回传 1 笔,有时回传 3 笔,是不固定的1 W* |/ R. n, u1 h; c# J; v) E
回头查语法定义
% H7 y0 g1 _& J: F% x2 {3 p- Pwith % Z) N {# d+ D2 Z3 h
agentset with [reporter]
. _. {' ~2 i, A6 VTakes 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.
: o+ o* s( l' U, z它只说回传 agents satisfying the given condition$ O/ g. ~8 \8 B( l. W+ W
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
, U. ]8 _4 R: K3 Y, ?- x( t
3 r# `1 @7 t8 ~& p: h$ Q) F想确定一下$ b' x9 q; w8 [( c$ u$ }! {
谢谢!
2 r/ h9 i9 p: D' o9 Z |
|