|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
9 Q h6 b% r) |: @( c2 `其中有一段如下" ^3 z* x2 |* u$ C) W
ask turtles with [ infected? = true ] & f. m2 \) s) G% J1 e6 e8 R3 Y
我原本以为这句会回传『所有』infected? = true 的 turtle0 F& @* E4 R' A0 o
但看结果似乎不是这样。. L5 j3 M$ w( t: D, c" J" Z8 R* B
3 y+ Q, Y- o+ E假设所有符合条件的有 5 笔
" g; ]/ e4 d% S5 E% J2 `有时候回传 1 笔,有时回传 3 笔,是不固定的
- H6 T3 g' C$ b0 J回头查语法定义
; W. y$ X, T6 m# d! L4 ywith
! ?1 K$ X2 D" Z) d u. ]6 w& Bagentset with [reporter]6 J( ^% g3 N$ y: p& w; G- }
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.4 ^/ p0 N f- S
它只说回传 agents satisfying the given condition) @( i9 N2 [ t# I/ i7 u0 |& |6 S
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
$ o$ n- Y4 P; L, l4 f8 t
) _5 u( F+ Z1 U想确定一下; r# F9 {& ~+ T) N- V1 \0 ~
谢谢!. J1 N' A4 W- S9 B, p+ }- L+ x# H5 p
|
|