|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序* `- Q3 U! y# Q# k1 J, \# k7 R
其中有一段如下
" O$ e1 W& P I1 C" f# a" }ask turtles with [ infected? = true ] ! m/ C9 N8 C- B/ C4 c
我原本以为这句会回传『所有』infected? = true 的 turtle
. ]0 B0 q1 `: U. I0 |" e$ {, A但看结果似乎不是这样。
8 O0 S. ]; L8 r1 A, O
$ q* p$ O' }5 d$ ^假设所有符合条件的有 5 笔
) }6 G, j3 N4 ?$ g+ z有时候回传 1 笔,有时回传 3 笔,是不固定的9 [: n: F4 t+ Z, X
回头查语法定义
" p/ y; E0 l6 a* E5 ~& kwith 0 |& c% N& L/ v: j
agentset with [reporter]9 Z. ]- N7 K4 U1 ~: \/ b7 i
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.
# H) x( Z- v' b" T它只说回传 agents satisfying the given condition X+ R6 [3 r( u* t
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? * ?* E+ I/ ?, j4 Q$ x
) A0 s$ \/ H8 d7 p7 w5 }. w' {* r' }
想确定一下; K* w. Q" b: A; D! Y
谢谢!9 n* w5 d- `+ H' B
|
|