|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
% O; S4 v& `4 L5 [1 J$ x* A其中有一段如下, ^5 p9 m3 U$ w+ A3 i3 q
ask turtles with [ infected? = true ] , t) z5 ~4 |9 m0 z, ^6 r
我原本以为这句会回传『所有』infected? = true 的 turtle
* [8 j# ^# I& P3 n/ U$ V( i但看结果似乎不是这样。
( r; V- H- y6 a: X/ R7 `4 R% J" |' F) y1 I9 `! s1 ]! j0 n/ z
假设所有符合条件的有 5 笔$ v& V, T$ S0 c- Z" T6 c
有时候回传 1 笔,有时回传 3 笔,是不固定的% X: V7 B& v4 A! m. Z d
回头查语法定义$ S) G! k4 y2 S7 Z9 v# F" T _1 N
with
9 s0 M4 W4 N: g2 E" O, Magentset with [reporter]" B# R: d/ r& f
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.( a7 ]$ I# w7 D5 o# z
它只说回传 agents satisfying the given condition! s& ]2 j% ]9 M: \8 C$ v* I
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? : `: r# \8 |" b$ H
0 Z | Z0 _, b& N. V( r0 w, j
想确定一下2 o7 Z; C' F- [: z* o1 t/ Z
谢谢!
! q9 a* z+ h- v9 T# _5 R( D2 n- Z |
|