|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
, q" F1 I ?# [* ]其中有一段如下
- u& C) G4 F) {! A- H! ^ask turtles with [ infected? = true ] 7 p k3 m6 |% U# {2 ?' {8 A, N( k4 Q
我原本以为这句会回传『所有』infected? = true 的 turtle# G9 k3 ~& h" |
但看结果似乎不是这样。
7 x7 o; ?4 i) {
l K7 F h# H假设所有符合条件的有 5 笔/ u7 d& e; L! K
有时候回传 1 笔,有时回传 3 笔,是不固定的0 r9 n: B/ T. V
回头查语法定义* P5 {2 k! h( k6 d: p: M T
with
' G$ Y6 l( Y+ y* xagentset with [reporter]% q$ N6 m% S4 n) a$ k1 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.
- _) m* I( Q2 D它只说回传 agents satisfying the given condition
; F9 [8 v$ O% }是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
- g7 Y: \* [$ M, \% d0 I8 i
, Q/ U/ ~0 U7 N$ n$ C! V, a2 P想确定一下0 X+ A* P/ d5 o9 `; f8 d. {) U' S/ t; V
谢谢!
8 Q$ B- F% O4 B* V) w) Y- a9 e |
|