|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序* N( H, [ k* r! y! ^8 S
其中有一段如下: `: K: p1 k2 O, c( Z
ask turtles with [ infected? = true ]
. ^, V+ g) b& W6 }% p) `我原本以为这句会回传『所有』infected? = true 的 turtle5 w4 _& r( v/ v) ~& S \1 [
但看结果似乎不是这样。. P9 D% V- I& p4 h# V" Z/ r; O
7 F X' z' w- w( D
假设所有符合条件的有 5 笔. _: s$ x: `* ^9 S% |5 I
有时候回传 1 笔,有时回传 3 笔,是不固定的
$ F) _6 ?( {1 C$ c0 y回头查语法定义
2 p+ o3 y* s8 W iwith
4 [3 v% j4 |( o( [/ C" A. [$ Gagentset with [reporter]- L4 M" E" n+ _6 \
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.
3 E0 d, C+ b2 m, F- S9 s它只说回传 agents satisfying the given condition; M. R0 c8 D) ]1 Y# u2 h
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
+ J) c) m+ k2 A6 Q4 p; x3 v- {
+ M' n$ @! m9 u" w! i/ r& ] L想确定一下
* r9 E1 p: C* e- y谢谢!( q5 s! l, j9 P6 j2 F: {) P
|
|