|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
* g" j7 J! X1 Z2 ^7 }* K其中有一段如下
* p# h5 C! _/ X! Z2 j/ W* Vask turtles with [ infected? = true ] ( t+ M) k; E8 B1 v5 _
我原本以为这句会回传『所有』infected? = true 的 turtle6 T9 E o1 M. S& v J
但看结果似乎不是这样。
& x; N* I! e7 m# _# O. C. E
# S) E6 \: t j% ]8 o假设所有符合条件的有 5 笔: r q" r% ]2 o [1 R3 X# C
有时候回传 1 笔,有时回传 3 笔,是不固定的. Y6 \4 O) }. a2 x: o! ~, l
回头查语法定义0 J0 Q' p- P; l. S
with
4 X0 h" V% F" M: P$ A1 magentset with [reporter]$ V4 a6 ^6 l4 Q; Q$ j/ W
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.
; t1 a2 K4 ~- T; D* @它只说回传 agents satisfying the given condition3 Q# t4 _5 g% r3 R( E* g3 o
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
' V2 V: J# ~" b) O
8 v. g) b# v6 T3 V7 X9 f! v4 N想确定一下" K* [1 r5 b! o
谢谢!# p$ M* V( l8 X! Y h% ^1 E
|
|