|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
; W; A7 `# E" Q& [ G; C9 F其中有一段如下' \2 N! h$ B5 B- f8 M; U
ask turtles with [ infected? = true ] # p) f' x. ?8 v5 f2 \/ b. e, a+ A
我原本以为这句会回传『所有』infected? = true 的 turtle
7 ^$ p" J' x( |0 l3 t# d8 v$ B& y) ~但看结果似乎不是这样。
3 E1 b y/ x! R( s
/ K" w9 C( Q6 k; j! L假设所有符合条件的有 5 笔 o; B. h6 }3 v0 a j
有时候回传 1 笔,有时回传 3 笔,是不固定的 b7 Y% [( M# ~1 f
回头查语法定义
% W- J* u/ I. Y- M8 qwith
% r5 o5 ^( D' _4 W" }4 xagentset with [reporter]7 V" _3 ]3 ^* J) M& z: e. l
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." q' ]/ s* v7 p0 y
它只说回传 agents satisfying the given condition
; P; F! ^9 V1 k5 H# k, T7 Y是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? : P! m: ] }! v8 T7 a
8 x( }. f6 ` }
想确定一下
( F# q1 j* Z8 N e+ f9 q谢谢!
: {) C* Q" m4 \! \8 ]$ o |
|