|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
+ J- A. b4 O' W; P其中有一段如下
* o. a& S3 m4 ~3 o3 wask turtles with [ infected? = true ]
2 n4 G1 `6 i5 @7 V( m0 v0 m我原本以为这句会回传『所有』infected? = true 的 turtle
" m/ ]4 }& ^/ ^: I但看结果似乎不是这样。8 W% L/ D8 A- n7 d! J4 }0 z
) I- n* O! W; R假设所有符合条件的有 5 笔" u# x: w" r4 A; Z2 q ?! `
有时候回传 1 笔,有时回传 3 笔,是不固定的
+ K$ c0 @" M9 d( c- k9 z, I回头查语法定义
7 l+ x- |# N9 Y) x/ Kwith
" Y! n+ h5 |- e F. magentset with [reporter]
8 _1 i: J) u* ]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.# c% A# ] w; ?4 Z/ b6 O
它只说回传 agents satisfying the given condition; J) { N T& w: p& D( [
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 4 a2 Y3 S, `% O
" z& J4 Y' @( D" f0 j( H2 q想确定一下& n' Y( X# H" C: a
谢谢!& R2 `) J$ t5 Y. j; f9 f
|
|