|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
* V& s5 L( o, V3 }: F9 Z其中有一段如下
* p/ x6 ]) U3 \& G% x3 \3 O& bask turtles with [ infected? = true ] ( \0 | m* y3 |3 ?3 d
我原本以为这句会回传『所有』infected? = true 的 turtle1 R* v+ U1 o3 C. V& ~+ f7 r
但看结果似乎不是这样。" _+ ~ Y; E m: d& @8 K$ ^
! E/ [0 T- b& o0 Y) _
假设所有符合条件的有 5 笔
, G5 f& j S. m7 N; j" O! C# l) `有时候回传 1 笔,有时回传 3 笔,是不固定的
1 G* G; E1 V* y9 y1 {1 B) ?回头查语法定义
! f5 A" L0 T( C) c3 o' {with
& O5 @* E: }& b0 x1 | w; v5 _agentset with [reporter]
! ^" R$ @1 O1 `! u" STakes 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.
" L' O! E3 j; f' j它只说回传 agents satisfying the given condition
2 m, A+ F% q& ]; d6 A- G是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? ; }6 p1 i- L1 N* l
% O: `. l) i, y4 a9 C想确定一下
9 _& {) k0 b4 O+ A" z# M谢谢!
/ F1 K% x( u$ q6 d |
|