|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序+ }8 d" |2 D9 T& A
其中有一段如下
. T) a/ f A. @& Q9 p! `ask turtles with [ infected? = true ] c+ c1 j- [# s
我原本以为这句会回传『所有』infected? = true 的 turtle' ^. |2 h1 _2 m- A: t6 l+ [- s9 q1 l' z
但看结果似乎不是这样。
2 r* Q; p: }, e4 F; N4 U6 i' j1 S+ b) u) X: N- T5 J# h8 ~
假设所有符合条件的有 5 笔
\0 N: z5 T" d' m! K& J- X有时候回传 1 笔,有时回传 3 笔,是不固定的) j( g4 |# \$ F6 N. H- H
回头查语法定义
q2 X) X! d8 p; \ Q2 ]( J5 p/ rwith
* |: v2 ` e2 R1 W* u8 wagentset with [reporter]
7 L) c, o, w5 t* o5 f: G4 v; ?- 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 u+ c3 Q+ t$ K6 Y
它只说回传 agents satisfying the given condition) U7 n$ @2 D( l; M% `0 G
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
8 c# B5 h: Y- m$ z* P+ M# K N& B' _5 G% X) C; W
想确定一下7 ?4 G0 Z# } u7 y
谢谢!0 ^, [. G8 e0 ^# ^: h9 i& N
|
|