|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序7 M2 `4 u. ~! L0 T! r8 F8 `
其中有一段如下9 D5 g7 U: k' C& ]8 j* W
ask turtles with [ infected? = true ]
/ s: ]# M- O( |2 e我原本以为这句会回传『所有』infected? = true 的 turtle
* K, m5 v6 h% w& F; V( a* x但看结果似乎不是这样。7 Z2 C" V& e5 J* h3 }0 g; K1 X3 V
8 a3 i+ u& N4 p2 ^假设所有符合条件的有 5 笔
' _/ B5 }7 k; E. m2 N; ? H2 m& s有时候回传 1 笔,有时回传 3 笔,是不固定的
5 A- E. U; N# P/ i9 `回头查语法定义
6 T" j2 k; t0 u+ Xwith
! w F& M! u( p% z5 wagentset with [reporter]3 [7 O+ q* Q) A& S6 o
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.) X5 V( S1 q7 j: _3 {5 _
它只说回传 agents satisfying the given condition9 q* D% j5 B. D
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
+ O" w4 B- V, C% \ L, t, Q; L0 }& B. E2 x: z- A& F) {
想确定一下
l. ?% \% k. R/ ^* T谢谢!4 B" v: C% H" p/ H+ m' E
|
|