|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
* h7 r" Y9 V6 f+ ]( M' h4 V其中有一段如下- O w" C2 X" N4 u* k; B0 w: N3 G' t
ask turtles with [ infected? = true ] , q5 H5 m' i& M( Q# h& ^
我原本以为这句会回传『所有』infected? = true 的 turtle+ l! E q+ F/ }7 b6 q, q. ?7 M$ p( W
但看结果似乎不是这样。1 }1 R+ U: J# D
4 b/ J- e3 h" }9 K( r" i假设所有符合条件的有 5 笔
+ s( B' s: _2 ^. V4 S有时候回传 1 笔,有时回传 3 笔,是不固定的, V0 F3 y* R. t* S0 ]7 t
回头查语法定义8 l! k4 O0 J$ P9 G+ e* w& \
with
; K; _* U1 U9 J+ N& ^7 V; Qagentset with [reporter]5 I+ \( ^# o+ 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." D, ?' j/ E% Z+ A
它只说回传 agents satisfying the given condition
. v% D5 W" T1 B+ {是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 7 C/ i/ f) D0 F% Q: K; J% R) }
1 c: a: U) V: n: O2 Z想确定一下7 Q2 s$ K+ A9 m0 O' J
谢谢!0 I4 N) |; {* l# P9 q" \+ M8 L. G, S
|
|