|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
" Z- V9 Q+ f' M3 f! y) j# K: W其中有一段如下6 u. l" O& O( m% e& c
ask turtles with [ infected? = true ] * ^3 ]4 G E( U
我原本以为这句会回传『所有』infected? = true 的 turtle
; d9 `2 }0 O" }' \: s6 x0 i0 _但看结果似乎不是这样。
( q; J3 {- t, D5 d8 U. M
/ N3 B' z! [( q9 k假设所有符合条件的有 5 笔' g: b9 q3 d q7 x' p6 E( w
有时候回传 1 笔,有时回传 3 笔,是不固定的
; d' { t* V+ a' ?0 u2 {8 A z回头查语法定义' c2 |2 S* L4 |1 D. X. r
with
1 @& w, s i1 V' e- ]6 yagentset with [reporter]
+ b* E) y% E) Q0 _3 K# w6 W# y4 nTakes 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.
) i/ \$ c& f- V3 U2 @它只说回传 agents satisfying the given condition3 S; f5 ]2 l* a# [+ p
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
$ G; d- M. f3 W# j1 K1 S) z
$ {* h4 `. g: |* a7 ^* {1 X想确定一下
' J1 H5 D5 J- u7 Q2 c9 [谢谢!) \3 r0 M2 a; I) c3 D
|
|