|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序4 H" G' R5 i7 r. Q$ y6 D
其中有一段如下
- A; k6 ` j$ k; s" l6 rask turtles with [ infected? = true ] / e: V* [$ [) t. H5 U f9 l
我原本以为这句会回传『所有』infected? = true 的 turtle
# d6 E' F4 x) S6 ]8 T$ P, i' [ X但看结果似乎不是这样。
. a! C G8 D8 `) j r3 Q- f u0 N$ r9 a
假设所有符合条件的有 5 笔8 [, U* C2 q4 T6 z
有时候回传 1 笔,有时回传 3 笔,是不固定的
8 w( }% m' C7 q2 ?回头查语法定义" f) }3 D5 T$ D
with A; c& A0 m* A+ L, Z& R
agentset with [reporter]3 W! J- i3 Z5 c' V: p0 E y
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. y5 @3 m( d8 {* b
它只说回传 agents satisfying the given condition
4 x( Q" v" I. ~! t是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 2 P3 ^1 S5 p" S& p. J9 M
+ I# A4 \3 g" w
想确定一下
4 s% f& @2 k4 J! ]谢谢!
. K) q' j" H3 t* d7 ? |
|