|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序$ P" I$ J5 G: c6 w
其中有一段如下' G1 h- C9 W% O
ask turtles with [ infected? = true ] & L: y( W6 H; P7 l0 D( E. Y
我原本以为这句会回传『所有』infected? = true 的 turtle2 k& [4 z: F) {# z7 E+ @# B
但看结果似乎不是这样。
! ?' w7 N( s- Y$ j0 p: E; _
" p6 J {8 z) P- {8 L, j0 `( i假设所有符合条件的有 5 笔
( g- I! o7 O4 N' g" l- _有时候回传 1 笔,有时回传 3 笔,是不固定的
* b5 D6 A! J" x. E N7 Z i回头查语法定义- a$ ~2 O6 }) a' G! p
with
$ P& [, N4 d' ^1 V7 sagentset with [reporter]
* \8 v, ^1 O: G9 B7 lTakes 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 y5 @1 E! X4 s3 _" @/ x
它只说回传 agents satisfying the given condition
4 E1 N+ x- p% I" t+ n, e5 d7 |是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
) n3 o6 e1 V& _! u6 B0 C6 ^0 @5 s9 `5 H2 F6 B0 t9 [% Q+ Q+ [
想确定一下9 z3 |( t, e" X
谢谢!& d$ Q2 A u/ B$ E1 r2 u
|
|