|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
+ W: d8 W2 p _# j" U2 x$ c# E, K" }' ~其中有一段如下
/ t0 q/ @6 f% kask turtles with [ infected? = true ] 6 E- V+ O% x$ X$ |0 Y
我原本以为这句会回传『所有』infected? = true 的 turtle
! ]8 r2 H3 U/ K( s. H5 k* o! R但看结果似乎不是这样。
2 ?% P" L1 b x* Q3 ^, x
# p% E' ^$ Q- R假设所有符合条件的有 5 笔
: y! Y6 g( q& N5 w- F1 I1 q# t; s有时候回传 1 笔,有时回传 3 笔,是不固定的
7 R: f0 I [! O8 a" a$ H' V, L) H回头查语法定义. `& V- Z; K* G5 C, V; e
with
. d/ P5 |3 z# U; S* _agentset with [reporter]
( M1 p& x0 u/ i! [. rTakes 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 e* o% [3 I, j3 S! {8 k$ ?
它只说回传 agents satisfying the given condition4 l5 a0 z- z8 s/ X
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 7 ]' @" {! U3 D
: l, j( }/ A6 W q( g' t3 x想确定一下' n' \. V3 t% n% Z- Y$ P
谢谢!
% b7 N1 l# c4 a |
|