|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序* V2 l1 Z) X. e
其中有一段如下
/ |+ ^0 f# s7 j$ q3 s* t0 vask turtles with [ infected? = true ] % E" o& O* S8 ]
我原本以为这句会回传『所有』infected? = true 的 turtle x9 ~ t. ]; n; F0 [; X1 _2 A
但看结果似乎不是这样。: t/ B5 X8 v6 B+ l J% O. F
. S5 q2 X- S; [1 a l
假设所有符合条件的有 5 笔
( z5 ~! e+ o5 H9 Z7 M7 c2 e2 H有时候回传 1 笔,有时回传 3 笔,是不固定的; A$ W" u4 N( I: e" ^9 o
回头查语法定义
+ ^. o( Q- ^/ p2 I/ u( Ewith ' B( w, O0 a$ L) `7 H# p8 _
agentset with [reporter]
6 P* L2 Y7 `% \7 l |5 ETakes 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.
& M! z- d$ n: A' K3 x% B T它只说回传 agents satisfying the given condition& k: U8 J" w3 U3 h0 M: n, B) L" T
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
, ]! i; L$ r; X2 w4 f4 x4 q
8 m& v% w" _4 i+ R想确定一下 c5 v+ }9 y, Z) A# G
谢谢!
/ L: |8 x$ O" N |
|