|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
; \1 K% P7 m4 X: D3 j9 `# W其中有一段如下
1 K8 W1 x5 ?+ {4 K: T, v6 Hask turtles with [ infected? = true ]
+ l2 }1 L& h1 A" Q$ E$ H. _我原本以为这句会回传『所有』infected? = true 的 turtle) G- r0 E/ s: F8 y( U* i4 G2 c
但看结果似乎不是这样。, S8 K3 `8 D0 Q4 o, ]* O5 |" e
' e- }: \, T: F; ^/ X
假设所有符合条件的有 5 笔9 ~5 S, h g$ i
有时候回传 1 笔,有时回传 3 笔,是不固定的/ k0 B! _0 ?+ y
回头查语法定义 D6 ~% N. e/ J9 n# V' R+ h
with 1 T9 i& q7 g% I2 Z( A* e7 }+ v
agentset with [reporter]
/ S4 }5 Z0 X1 |/ pTakes 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.9 b* y* s: c. x+ N5 N1 S
它只说回传 agents satisfying the given condition0 b8 T8 v9 D7 p: s
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? , x4 p8 v. E; O% m$ }
7 F. j/ i. \4 L8 l
想确定一下; m0 ?& t& L T, a y
谢谢! k0 J) W$ [8 x% Y! i, R* K" A
|
|