|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
& {& _6 V2 ?2 y# o5 T3 K. x4 k其中有一段如下
, u* U4 S& L) J" Eask turtles with [ infected? = true ]
" ~- l; R4 f" E1 N& c! l9 R& V我原本以为这句会回传『所有』infected? = true 的 turtle
7 ` x6 z5 A- p V$ Q但看结果似乎不是这样。4 [: E) c' W0 O/ A3 ]% N$ v0 l
1 I5 E2 N. g- G" u F% A假设所有符合条件的有 5 笔" s+ b# K& N$ r. E+ w
有时候回传 1 笔,有时回传 3 笔,是不固定的2 _3 S% o7 V0 N0 q2 @
回头查语法定义
' L& |* X6 n# s Hwith d0 `" f1 L6 o9 k
agentset with [reporter]/ B. {& M$ y9 ~% N
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.* D) A+ f6 x% W0 q/ c: Y; Z; T9 p
它只说回传 agents satisfying the given condition5 ], M5 a2 C9 H# q
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? # f* @' t1 Z6 l( ~( Q
/ `* {4 f% \1 C+ S9 Q
想确定一下% u+ b/ z$ v! e5 y) d& C/ Y
谢谢!; w+ {! ^! {8 g! V2 ?1 `. y8 p
|
|