|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
1 `' Z+ B1 f3 j, R2 `& P# U其中有一段如下
2 s) `) f% s* ^3 t3 B' b# G$ s6 _ask turtles with [ infected? = true ]
. u O( l, a0 J j$ l我原本以为这句会回传『所有』infected? = true 的 turtle
3 G5 E, v T0 |# @1 A \2 {但看结果似乎不是这样。
' q) N3 A ~* f, y
% m d0 d% {8 p3 F' S9 R假设所有符合条件的有 5 笔
' x( H- } o- y8 ^2 O m0 E' Y有时候回传 1 笔,有时回传 3 笔,是不固定的9 n/ J% t$ Q& B7 p7 k' t9 n
回头查语法定义* l; k/ H/ A4 p
with
4 r3 f% f7 W3 c9 T0 \: _. hagentset with [reporter]' {& V9 }" l3 Y5 \ x! a [
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.3 K) r' ]5 l5 R- v# {+ v, P
它只说回传 agents satisfying the given condition2 U/ O; ^0 A3 M! v0 H1 T
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
2 u- C2 e. T a% l) H1 a2 K. t- r2 e! l: U- c/ M
想确定一下
% w9 ?# D7 U& D$ z& b K* |谢谢!3 M# G. y' i4 G& w- [
|
|