|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序% D# y. S# R/ k5 L/ O2 p
其中有一段如下
) @% o$ E$ S& q& wask turtles with [ infected? = true ] ; l0 h( Q/ U% u1 \& P9 B
我原本以为这句会回传『所有』infected? = true 的 turtle0 R9 P% i& Z/ W% f' U! q. x- J
但看结果似乎不是这样。- A" s7 M1 h2 T5 ~8 e# M, _* [9 q
7 E7 }3 z% g }/ t$ D* K; k8 K6 \
假设所有符合条件的有 5 笔
" K0 U& y9 I, i J* N/ U. k% {有时候回传 1 笔,有时回传 3 笔,是不固定的9 _; I- W5 S( x; v+ M
回头查语法定义/ Y7 K, [: V# b" h( k0 ~
with
, c; `. @! Y' B6 x4 [agentset with [reporter]
2 w2 H( J! x; ~, DTakes 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.# c% Y1 [- s8 Q- U* }4 P) s! Y
它只说回传 agents satisfying the given condition3 O' K$ e2 Q$ `" F( A. o* c
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
5 L8 o7 V7 _& n8 }- U8 i4 M0 l$ n: N
想确定一下9 S' Z* x9 x; Y3 m$ K3 v; O& {: k
谢谢!
8 k+ U) ~& P7 [( ` |
|