|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序7 H4 K5 y0 E; x/ {/ x+ D
其中有一段如下
" T* I8 R- T: g. k9 Xask turtles with [ infected? = true ] 6 I3 }6 ]! |% h, k" d$ P9 J' e2 Q Y
我原本以为这句会回传『所有』infected? = true 的 turtle
" `/ Y8 a/ N! b$ B6 S但看结果似乎不是这样。
( [7 G! B/ W7 V# l; V7 Y K! r+ @* S! t/ p/ e1 X' J/ n. ^" Y
假设所有符合条件的有 5 笔
0 D4 N' Z$ Y$ b有时候回传 1 笔,有时回传 3 笔,是不固定的3 D6 q) {1 [2 c1 r' T
回头查语法定义8 p) z1 Z9 ]9 Q% M
with
1 j, k+ G1 Q! l: y- {5 Eagentset with [reporter], `5 \$ n5 y U- r+ c: R+ }
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.: T* r; g: H6 S) t* g
它只说回传 agents satisfying the given condition ]9 ~# H6 }. |6 Z. A; T5 E
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 8 M# a0 L7 ? C: g
' Q; D( s$ r: W8 ~想确定一下
8 x' \1 d; F! T0 @& J1 B+ d谢谢!; O0 {8 H* ]! c
|
|