|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
: j3 R: x5 @/ \4 ~其中有一段如下
1 D4 M) g- O$ p Eask turtles with [ infected? = true ] / _7 \/ ^- `& Q+ l) g9 y
我原本以为这句会回传『所有』infected? = true 的 turtle+ q; \" U8 d( I G5 Z( E
但看结果似乎不是这样。
) y, N0 }" C# }
; h% T$ i7 D, b( j: [4 {9 R假设所有符合条件的有 5 笔
2 J. Z) P+ U+ ~9 ~+ i有时候回传 1 笔,有时回传 3 笔,是不固定的6 t7 \; }1 Q& e
回头查语法定义
8 C0 w b5 V( t* o+ ^, X. Ywith 9 g* U# K# `7 y X' V/ V# G
agentset with [reporter]/ J8 |7 l S6 Z" `# f0 F z
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.4 V7 e% h0 a, g) S( e2 e8 o
它只说回传 agents satisfying the given condition s: d# Q2 t% r% L& P4 b) {
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
$ d3 D$ _, ^+ M j( q) a* W B8 z: x9 l2 L$ V k. F) w y
想确定一下
. {/ [0 \: h6 D谢谢!
. P: ~2 s7 y) }( w |
|