|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
, l6 _0 ]& G, T- f) G. \其中有一段如下
4 S1 k9 Q9 C' `, n. B$ [& |2 M' s7 qask turtles with [ infected? = true ]
$ d h2 I' D, B, I我原本以为这句会回传『所有』infected? = true 的 turtle- \; R/ c, C! J t5 D. g6 Q) y
但看结果似乎不是这样。- e; a5 n( V: ]$ `
1 e. S( Q1 K6 W假设所有符合条件的有 5 笔
9 ^ m% y+ Q# T# R B* o有时候回传 1 笔,有时回传 3 笔,是不固定的' Q- w6 w" _# W1 i' M
回头查语法定义1 F0 f- v! x* j3 L' T5 V3 l+ e
with
' @) B/ r& Y) _agentset with [reporter]# m0 c, T2 n3 L" r. G8 c1 J* o3 j
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.
- G0 B% x1 c; R( Q) F g* d它只说回传 agents satisfying the given condition: }% ^' `: F+ {
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
' w, w+ m4 ~0 x; @4 g! `$ O
* Q3 K( x' d0 A1 j3 y2 P8 V想确定一下
! ]& W2 b# v" H谢谢!4 G# ?4 V. h) C0 c2 s
|
|