|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
( p2 h8 B! B1 ]其中有一段如下& s w8 S# ], n
ask turtles with [ infected? = true ]
' Q' Y. U2 O+ e- E我原本以为这句会回传『所有』infected? = true 的 turtle
( j. L: g. s2 h3 A0 F2 L但看结果似乎不是这样。
2 |$ w8 n2 b$ x) N8 O% Q
{) L' j( y9 h* X3 {, C假设所有符合条件的有 5 笔- {/ M) |5 H+ J3 i
有时候回传 1 笔,有时回传 3 笔,是不固定的! o; b- L- F7 N) A4 u- T4 d; b! M
回头查语法定义
( ~* t' R& ?. A* v. O9 L# \1 d3 wwith
0 ]0 v* Z: k, O# A( `3 j/ Wagentset with [reporter]
; h0 j, Q, ^/ w# VTakes 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.- Y+ }' g0 \+ g: o. a
它只说回传 agents satisfying the given condition
' _! }. @0 o1 ]& k* ^是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
+ y5 v1 t+ ?% l! T4 ]: E0 J
! s4 f; Y3 @6 N想确定一下* x A2 ^5 O3 T5 ~
谢谢!7 H/ _% K% _4 b8 f8 f3 y5 J. V" T
|
|