|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
- l& ~9 B2 `3 J1 T其中有一段如下
7 o$ J! Z- w, M: wask turtles with [ infected? = true ]
1 s( ^1 z+ _$ v8 z% F/ n4 `7 x我原本以为这句会回传『所有』infected? = true 的 turtle
4 j/ T; D! X9 U) i! [但看结果似乎不是这样。
2 l- L, _3 S: D* `: x! m8 }# p; i" ` M J
假设所有符合条件的有 5 笔
" x! r% B* j, y9 y! P, u有时候回传 1 笔,有时回传 3 笔,是不固定的% d4 {3 a4 f7 i2 `5 i5 M6 ]
回头查语法定义
1 J: g4 C9 Z5 z9 R4 W3 Qwith 7 \9 E) O" p" J
agentset with [reporter]
! u5 d" |* |* _+ C6 w' X5 vTakes 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.5 w0 R# m. Y& w& v
它只说回传 agents satisfying the given condition
9 `) Y, ]7 x2 {$ x是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 8 `- u6 J: V8 \) ~
' Y) l2 |0 O! e. K8 X+ k8 s( `( a
想确定一下3 c2 j) E9 h9 S, Q
谢谢!
! C: |- p$ K' S! m6 v |
|