|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
* k* B1 W3 A- `/ _其中有一段如下
! |. p2 d: y: s# H; U! m% ~1 u: z" kask turtles with [ infected? = true ] - V: o5 C) l2 \' T6 N
我原本以为这句会回传『所有』infected? = true 的 turtle
: Q6 q4 y8 T+ R6 M: F$ F" q/ g但看结果似乎不是这样。
* O v8 M0 R$ L" {; h4 o8 Z' q- o9 Q
: ~3 I7 j8 b2 ?( p" w假设所有符合条件的有 5 笔
! Z$ H& W i& M4 v有时候回传 1 笔,有时回传 3 笔,是不固定的. k u; y! h5 r3 E8 d( Z% ?
回头查语法定义$ s! S. U4 e& l9 \
with 8 o* E2 k4 M7 {
agentset with [reporter], x* d+ t6 s, |, ^5 P
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.$ O3 g- E# {3 D* K# | v7 {
它只说回传 agents satisfying the given condition
. y; ?3 f$ W1 R; @- B0 K" w是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
- \' z! h4 }. k0 g5 O* ~( @& v4 s: V% f
想确定一下8 d( I; X3 [, _3 H1 W: ~, ^/ N" G# L7 I
谢谢!' a; r8 u* [! I6 x5 l
|
|