|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
% o2 T+ ~; V. b W q1 Q其中有一段如下# l& p4 t: B. Z9 @- D9 O& v2 j" x( n
ask turtles with [ infected? = true ]
r3 f% \& l/ s7 o我原本以为这句会回传『所有』infected? = true 的 turtle6 D. A" ?% ?" Y5 I
但看结果似乎不是这样。2 G, x% ^0 L4 z- G3 C$ L
3 J& b. g' O0 o6 C
假设所有符合条件的有 5 笔+ B& r' j$ {1 B' I z" w4 k& I5 e
有时候回传 1 笔,有时回传 3 笔,是不固定的9 I0 K% v3 S& P, D
回头查语法定义& v" c0 m U: }+ b, l, @( `+ b6 g
with
) Z# H8 e1 N% w8 eagentset with [reporter]3 S( ^, L: p% W i1 D5 A4 k
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.
& K( E& L9 C! N( \它只说回传 agents satisfying the given condition
/ w; b" @: M6 G# e2 |是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 0 R$ H4 |6 N/ T# }0 L9 w
* _( u& L: x0 Q* O3 `& t# W2 d% ^% W想确定一下+ X+ x+ }5 I* \. l; h+ V
谢谢!
" j9 e% R' t: ^# M |
|