|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序1 V* I: }1 i3 o! \: T1 m0 K' n
其中有一段如下
8 u1 n6 O# C; e7 b. aask turtles with [ infected? = true ] * N+ {& M9 Y7 d0 c$ X0 ~2 ]3 w
我原本以为这句会回传『所有』infected? = true 的 turtle8 Z* D/ ?( J/ T1 I
但看结果似乎不是这样。( |- \' K$ h1 x- _; ]9 b
; N3 O+ k) E! w) z9 `4 Z假设所有符合条件的有 5 笔
' ?0 a& t) q! n9 U1 \( z+ F8 O! h有时候回传 1 笔,有时回传 3 笔,是不固定的8 }. a2 f1 y1 |0 P( b9 H
回头查语法定义6 I1 i/ E2 b+ S, T. g( R0 N
with 3 K, ^. X. {4 [1 B% t
agentset with [reporter]
8 J5 S, o; u2 S0 I- Z$ oTakes 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.
- k! c5 J0 ?% u" z& ]它只说回传 agents satisfying the given condition, @( q: m' c( Q, F9 ~/ R+ X
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? ; p% ~7 Y7 W& M6 s, I! a
/ b( }& ~% \ O. u- h3 q想确定一下# [% p3 k m% U* {' Y: ~
谢谢!
1 M! v4 W N: \8 I! O: B5 Z, ^" Q |
|