|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
, S- Y7 W) K0 H# }# z2 ?- }其中有一段如下
" n9 W5 |% ~$ i! W" ~ask turtles with [ infected? = true ] . k+ c ^6 c7 j7 c# Q! b
我原本以为这句会回传『所有』infected? = true 的 turtle
: `* {" ]% Z5 P但看结果似乎不是这样。3 ]. u; n. v( c) K. ]' r
4 y& B4 W0 e4 D) H
假设所有符合条件的有 5 笔( K6 d5 V; N: S) [
有时候回传 1 笔,有时回传 3 笔,是不固定的
/ q' E4 Y7 V, ^2 x" v' k回头查语法定义
3 c! c1 y" k( X& Y3 Y$ Mwith . ?6 u$ y8 g9 b5 T
agentset with [reporter]0 e" [9 X. \+ J, Q, I% z4 V) Z$ r4 l
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.
- m8 b* q( t( t) ?它只说回传 agents satisfying the given condition
7 G/ e- s; w- B是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
4 _+ ~0 j) |& q Y
( P; |2 a3 Z5 `1 }2 v) H想确定一下
6 N" K& k3 o, m谢谢!
3 N! T$ n1 g; h2 E- B0 Z! y) P5 { |
|