|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
! [- Y+ M) E4 i7 x- {2 b1 {/ W* _其中有一段如下
0 F0 K6 F5 d- g+ gask turtles with [ infected? = true ]
1 M. j. E# h5 t8 I: t1 {我原本以为这句会回传『所有』infected? = true 的 turtle
: e- |/ I1 W! ~4 K8 E& A# M但看结果似乎不是这样。! W% [6 ? Z5 n3 t6 f& N. U
# c/ e, @( ^+ M4 M假设所有符合条件的有 5 笔$ }4 d/ D$ r& G" G% A
有时候回传 1 笔,有时回传 3 笔,是不固定的
& E f2 t5 R" @; Q; a回头查语法定义$ H- d# r1 J# ~0 K
with
7 \2 a$ I1 D$ i% V* fagentset with [reporter]
8 O }6 y/ j+ t2 W, c. a! U6 k" K3 JTakes 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+ I5 q% `" d, W9 Z' u; N3 D
它只说回传 agents satisfying the given condition! Y% R7 [, p! E' s% k
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? : j6 m$ P/ K5 l! V, ~( D+ u3 u; E
7 B' X; h8 i7 @0 u, t1 {9 N想确定一下
1 R7 Z0 |6 `4 l# O$ B9 F谢谢!
* I8 y! z( F4 V |
|