|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序; {" Q) \4 a0 F7 n3 ^9 ?
其中有一段如下
* ~2 h( e Q4 e; iask turtles with [ infected? = true ]
" B/ Q& H9 g" p/ P我原本以为这句会回传『所有』infected? = true 的 turtle
$ J1 u2 a7 \" y+ r3 @- Z" m5 b但看结果似乎不是这样。. m7 r5 K( _2 d3 R
; A7 ^6 N1 _* j2 |$ w: l假设所有符合条件的有 5 笔, }" A) ~* J' ^! p5 ^& J- T% j
有时候回传 1 笔,有时回传 3 笔,是不固定的! U! A& t2 i! B3 X* V2 C3 V2 I
回头查语法定义
7 J) _/ d8 H$ Xwith
% _: o& B/ P6 i7 I1 e% Fagentset with [reporter]# q- l7 T& o& _; e/ {: a6 a" A5 t( \* z
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.+ z* M- h4 k% E4 p0 i
它只说回传 agents satisfying the given condition
% J7 o! [' c, S0 y是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? ; V1 K @7 |$ h2 g( D ]
1 d1 V1 x# K3 ]想确定一下4 e* R7 d: T4 y: `1 N" c( ?# v2 q# N! y
谢谢!9 j" w7 L6 E# i' f" |/ m
|
|