|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
l4 P/ \9 |" y' C- e# f Z& U其中有一段如下
( ]& f$ X+ r: h# d+ f/ Z' Mask turtles with [ infected? = true ]
" m" _( X- A4 M" M/ S( z我原本以为这句会回传『所有』infected? = true 的 turtle/ r3 y, m: l& M6 n& u [
但看结果似乎不是这样。/ I) f; i7 @- E1 {
/ y& h' _: C* y9 e9 E( ^3 I假设所有符合条件的有 5 笔
" a% m( Y- U+ x9 q* e6 T9 M有时候回传 1 笔,有时回传 3 笔,是不固定的; K: ?! u. H, {
回头查语法定义( \1 L& u* h8 U2 e& F
with $ v; X0 A$ U8 T5 h( ^# Z T3 ]: M
agentset with [reporter]
8 E/ l9 h( R6 T2 M h1 P# `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.! u1 p! B. [; j9 ]
它只说回传 agents satisfying the given condition# c! r1 ^$ P; s+ ?( m7 X
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
" S& E8 q" Q+ u* V% q# a2 Z1 ^( N j0 m) J- v! a8 u
想确定一下
6 p5 C: `# k% Y8 x+ I1 a9 d @谢谢!: v) ?9 }% S" j. r/ p# q+ O% T0 E
|
|