|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序 N o) n- i( A: P
其中有一段如下
5 e+ W Z, D3 P7 a9 _, W0 task turtles with [ infected? = true ] & F3 ]! u' f' O1 I5 W% l- Z
我原本以为这句会回传『所有』infected? = true 的 turtle
; C: v, v& i$ u6 R# D) Y但看结果似乎不是这样。
5 i3 r$ w# O4 I- J& G! @8 q+ l& N ~) j
假设所有符合条件的有 5 笔
+ D% w8 B/ u: l5 q# s7 t( U: A有时候回传 1 笔,有时回传 3 笔,是不固定的% u" c- P* o9 {+ x" N9 O
回头查语法定义
( h+ Y" K5 O8 J7 ~with / w' I7 z3 o9 v: M$ u n2 }) ]
agentset with [reporter]0 G1 R4 u4 x9 H4 Q* _
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.7 r: Q/ C: ^. ~( ]
它只说回传 agents satisfying the given condition
0 ]* V" M2 ^! K是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? $ m- I' |! _0 S( X- C9 t
9 V! p$ I2 F/ O' l2 F: o6 [2 E
想确定一下7 F% |- N. P# R% @9 H: o9 K4 F
谢谢!
8 F0 Z* D4 m" {( F+ M |
|