|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序. B' c& f, I: v* g! y5 o6 R5 e% j
其中有一段如下
' {+ K: e& U$ i4 i, }( B! xask turtles with [ infected? = true ] . ]- p/ m+ q5 n' K9 O% C
我原本以为这句会回传『所有』infected? = true 的 turtle
# _0 D5 F3 m: t0 Z! E但看结果似乎不是这样。
2 K& K* _& g, W2 |
& j) _6 M3 W/ S8 v8 w% @/ u- L假设所有符合条件的有 5 笔1 |, [! q7 T& y3 A
有时候回传 1 笔,有时回传 3 笔,是不固定的 r8 ~- |7 Y. q# A! F4 s+ q
回头查语法定义
_8 F) ]2 n3 z. y# mwith / [# U7 s/ r3 n9 Y& C/ ~
agentset with [reporter]( m9 s8 h4 U P9 l) @9 ]1 R6 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.
/ A7 x" e% t; x4 Q9 k4 D; Y. |它只说回传 agents satisfying the given condition( V8 a. U: U# d; |- g% ~, w) f8 V
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? " y8 \0 d! u' B& K1 G3 h) P5 D y
# r- {- K- C. K
想确定一下1 o- z& r5 j, h1 A: r
谢谢!
# y/ N3 x( x% ~" U5 | |
|