|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
+ t) _* q1 o ]- ?. O% g( ^) e其中有一段如下
) v& {1 ?2 h' D2 X z1 Q. B) M7 hask turtles with [ infected? = true ]
# t z2 Q `5 M9 U5 i3 L, P4 \0 p我原本以为这句会回传『所有』infected? = true 的 turtle
4 P6 }9 _& o+ Q' J# Z但看结果似乎不是这样。
. {9 _) `& k* {6 U
1 M0 r% t' J% [假设所有符合条件的有 5 笔2 g* V+ z6 g1 W
有时候回传 1 笔,有时回传 3 笔,是不固定的
, g" ^1 X# f* ~0 M6 q9 S V/ ^# N回头查语法定义
) Q8 \$ n% ]9 N% swith ! g/ J! ^6 ?/ i9 t( G8 W* {9 j7 }
agentset with [reporter]1 B) G, _ {+ j& i' v7 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.
( G: I" Z* P- p; l它只说回传 agents satisfying the given condition1 M1 b% k2 a) e
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 6 y3 d- v$ Z) L6 @ R, I
, m" W; a5 ^6 o2 k( v2 N, `5 X7 q0 K
想确定一下
$ r9 s* G8 d. q# |/ `: B6 S0 t谢谢!) i% q! v) h8 a% c" @! T, x v3 L9 ]% ]
|
|