|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
1 w" ?1 J- w* n. T' q5 |7 d2 a其中有一段如下
/ P4 g- r+ t* H4 Fask turtles with [ infected? = true ] 7 o" m9 [$ e c8 @0 V# M
我原本以为这句会回传『所有』infected? = true 的 turtle
; F) X+ D0 J4 s: J0 a: Z但看结果似乎不是这样。2 d8 K. `% q7 @& V5 C$ _; @) z6 b4 B
+ ^" H0 H5 F" i& x* D
假设所有符合条件的有 5 笔$ R6 j6 Q! X# [5 m' f
有时候回传 1 笔,有时回传 3 笔,是不固定的5 x7 o) V% `* \8 a M+ ?
回头查语法定义- M% P# R0 r/ R% \7 D1 ?8 X, F* R
with / z/ G; G. w3 s3 l @
agentset with [reporter]6 ~8 C- |3 L" W/ z" Z! {4 t" ]' |; G
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.! S( _; f; M; b) ^) S( d9 l V) v( C4 x
它只说回传 agents satisfying the given condition# w# a/ k) [" C
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
6 }! h F% F2 x+ _
2 V- V6 d& }( x! a$ O/ f想确定一下
# V) `' e# ~* B# q. [* T谢谢!
) D- b( y; {9 G% h2 b2 Q |
|