|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
; ^ D. P; L( Z) d7 n9 d3 \1 @其中有一段如下
5 j$ L7 @5 n6 p) ]% f. U9 kask turtles with [ infected? = true ]
* k/ v# s |2 Z: H我原本以为这句会回传『所有』infected? = true 的 turtle- Y4 D- b+ c ]6 W
但看结果似乎不是这样。+ r( L# F. Q( x, |3 I" d& x, a
; a' a1 ~4 t9 A$ C9 Q假设所有符合条件的有 5 笔, v8 I- P' A; E, {
有时候回传 1 笔,有时回传 3 笔,是不固定的
+ c' V( N, P0 ^0 U/ E" G2 Q回头查语法定义
( L8 X/ o$ @, u' I8 z/ n2 nwith 8 x) T) C8 a0 `& E
agentset with [reporter]
- v5 v7 A0 Y9 g5 E k3 A% RTakes 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.0 b0 i* X3 Z* L0 \' m$ v3 D
它只说回传 agents satisfying the given condition, |$ b$ w9 J. [% }: V
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? # G8 j' Z2 J. I- l2 d5 m5 L
! |" p; V! J. W# k, U想确定一下
: z7 q8 ?5 `; u4 o y( O+ W S谢谢!
9 Y4 S7 C8 Y- K2 C9 r i$ M) Z0 Z |
|