|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序0 D3 r2 H$ y" N [
其中有一段如下
7 z6 D+ D, k& o) A. U- |5 Kask turtles with [ infected? = true ]
* k) u( J- ~ V4 D$ w I6 f: n+ y我原本以为这句会回传『所有』infected? = true 的 turtle& x9 p# u% W9 D* a3 V) r1 Q
但看结果似乎不是这样。5 K6 y3 H: Z, Y$ u# q1 g
7 R4 \# n' ]1 y* l4 g2 k
假设所有符合条件的有 5 笔: `; x. O# U. l( q$ `& O- [) e& E: t
有时候回传 1 笔,有时回传 3 笔,是不固定的) U. Q: j- q4 U# D
回头查语法定义5 M) A1 g9 u, ?1 s$ }
with % _, D" [# H% H
agentset with [reporter]
$ \2 Y' O5 e5 @" u2 a" gTakes 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.8 h) D$ x( {/ k; ^9 U
它只说回传 agents satisfying the given condition* v2 S2 c' o* Q) J5 Z( X, {) x; G
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? # Y0 t8 T0 V$ l# W9 X
; `$ |8 e9 g& u {6 v; W/ o
想确定一下
5 Q ~0 T' K; n9 W) B谢谢!6 F( s/ M; v$ I9 ~5 { f* \
|
|