|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序/ T+ o: s+ ~( a
其中有一段如下4 V; N+ X4 m p
ask turtles with [ infected? = true ] $ |7 B1 f: `9 Z0 k& {- ^% y% h) x
我原本以为这句会回传『所有』infected? = true 的 turtle
! q( U7 r4 E! k) @1 _+ f但看结果似乎不是这样。6 \4 ~% B; z1 _
$ ~/ G+ K+ i: \3 i假设所有符合条件的有 5 笔; S; X% `# M4 m+ L& v1 v
有时候回传 1 笔,有时回传 3 笔,是不固定的
; r: o: F, S0 ?% o! N回头查语法定义
$ Z( J! j+ e$ K, s0 q! Vwith
5 n1 e) |, }# ~; @+ |" ]! Tagentset with [reporter]
2 [- b4 a6 ^; X1 mTakes 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.6 J/ f2 T/ d# A4 U. R# H
它只说回传 agents satisfying the given condition
; y' T8 v* J ]% b) L是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
2 R0 J2 j3 g7 E3 u6 e$ r
6 D' P' v* d, J0 `! {2 D想确定一下
! j/ f; j% N6 U1 j: L7 n谢谢!4 I' m- b/ w0 _8 N7 N
|
|