|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序* L3 i0 }+ I* {) ^3 \5 o
其中有一段如下
& B. \3 s; e* ~4 e% k5 Z% }; d- Task turtles with [ infected? = true ]
) ?9 |6 }9 @- h! C# V) [" C5 V我原本以为这句会回传『所有』infected? = true 的 turtle
$ s9 C6 D/ q& I4 Q5 r# A但看结果似乎不是这样。
* u/ n7 s2 Q) E9 n% H+ J! ^9 R1 p9 i; M! E
假设所有符合条件的有 5 笔
) u8 H: y5 K, I) {有时候回传 1 笔,有时回传 3 笔,是不固定的- t1 V5 o7 X* X1 g
回头查语法定义
" ?* h' {# D" i& n% Z* a1 a4 Uwith 0 S$ W# N4 |. f& q* }9 b" J" }
agentset with [reporter]
+ B% f8 z4 D3 G. p: \9 o" T' \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.: P& s0 b! b5 B, b% x8 \
它只说回传 agents satisfying the given condition
7 [- S1 [7 E G i# g# v是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
4 u) ?% K+ [" r8 L6 c H% K4 b: L) i/ N/ f. G u' k
想确定一下0 Y! x& Y7 R' W0 T/ U
谢谢!
- e A1 k! i/ A" }4 z& E |
|