|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
( d+ u3 N' U0 t) O& D. u- j其中有一段如下
: A3 [: a: m9 U& _& m( f% F4 Hask turtles with [ infected? = true ] 4 [+ B. q0 a- U) j! D1 K
我原本以为这句会回传『所有』infected? = true 的 turtle
% S$ }1 l) a# U$ g( t( h3 M* @但看结果似乎不是这样。
2 V. S0 l4 @& r9 _5 R9 H8 x& v( Y5 B6 |3 J
假设所有符合条件的有 5 笔 h" T+ U) @! f- R, {, E% H. f
有时候回传 1 笔,有时回传 3 笔,是不固定的- T: B- L. g) F1 Z4 `
回头查语法定义; F* r% l/ i- I/ R8 N7 T
with ; x# W, Z. E. v2 ^
agentset with [reporter]# \& R7 g* u/ 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.
/ \6 F+ D$ U1 d8 T7 w. u& F, B$ f它只说回传 agents satisfying the given condition
" v2 }0 ^/ P7 b# k) T* [* u是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
+ ~% W0 q0 A* c8 L+ V+ u4 W; R S5 Q T) J
想确定一下
+ M$ f( ], n) w# M8 u1 Y9 B ?谢谢!5 k! f& n& x0 J& W! T5 q
|
|