|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
! m- \7 J/ b$ z+ Z; F: [其中有一段如下
9 D) ~" ]- T, T4 }% y3 t vask turtles with [ infected? = true ]
0 v5 q0 r4 B) o我原本以为这句会回传『所有』infected? = true 的 turtle: _9 T# ]6 K# R0 a& ?
但看结果似乎不是这样。
j; g$ g: r: B$ F* I
( C3 h% c" e# r! g9 B/ [- N7 [- \假设所有符合条件的有 5 笔7 o8 Q" T6 l8 I# b5 w& n1 {
有时候回传 1 笔,有时回传 3 笔,是不固定的7 c9 \8 k& ~. \2 B3 i) j
回头查语法定义
( A% A% ~ L8 x. Rwith
+ g) C# v, ^9 l ?$ gagentset with [reporter]
2 m, S: R) `5 vTakes 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.% H0 Z) |% A0 y. f! o N( M+ g7 I
它只说回传 agents satisfying the given condition
, h* g# x) N* T3 T$ S G( e是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 5 \9 g" r/ s) C& A: H$ s2 r
/ J& {* |( j6 {' m想确定一下2 h' [7 l) Q# t* J" P6 D6 V( u+ y* [
谢谢!
0 r$ o( p8 X6 i |
|