|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序# o; o# S6 Q" i8 b3 e3 _, S
其中有一段如下) ?- _& r( n. B4 \$ u
ask turtles with [ infected? = true ] 9 H# \ _1 u) T9 [
我原本以为这句会回传『所有』infected? = true 的 turtle- {' g( Y/ `* H% x2 D _
但看结果似乎不是这样。( c! Y' ]5 @, f6 z" n( `
" u$ t" g F' f/ m- j( z2 e假设所有符合条件的有 5 笔1 h' u0 R2 X& Z/ [+ w4 A9 t
有时候回传 1 笔,有时回传 3 笔,是不固定的; K3 F* b1 w8 l' M! U Z
回头查语法定义0 T0 N4 o3 i, V
with o$ o/ W: R) T V' r; h
agentset with [reporter]& }7 k5 l8 z; f* c
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.
9 b1 k) }) G# H3 P它只说回传 agents satisfying the given condition
5 I5 u% E; |! g. `是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 4 x+ ^* _1 G6 V
, s) Q9 B( ?* D( m. s5 p7 S4 v: [; W) D想确定一下
) c7 V% H7 W3 D) c' a9 K- z谢谢!5 f1 C% Q/ `; w7 M7 F5 \+ I
|
|