|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
% f0 y1 P/ U2 B1 \6 o其中有一段如下
& j v/ o5 p3 d. S9 \0 x* f' Xask turtles with [ infected? = true ] 5 Q) |# d; K8 s' W
我原本以为这句会回传『所有』infected? = true 的 turtle: ?# F3 `) l d) o
但看结果似乎不是这样。0 j5 K1 A: [9 u2 K t# j0 B5 e
5 C+ }" e2 F' k+ l7 {4 l
假设所有符合条件的有 5 笔* u a3 D% r. K" H3 m
有时候回传 1 笔,有时回传 3 笔,是不固定的
, q3 o! x R5 J' n2 D回头查语法定义8 s7 x: o8 ?: F( K
with
k/ g$ B& o" J) Bagentset with [reporter]
+ L5 K8 E) K- _0 Y4 ?: H( V, V+ KTakes 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., z3 ]+ J! {. V* f. ?
它只说回传 agents satisfying the given condition7 H; \( _; P+ c2 D* P& E* c7 N, P
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
( A8 O" i- _/ E5 A9 q- M: P5 ^( d( S) ?" J9 z4 e5 g7 p8 ?6 r
想确定一下& H8 c T0 b0 ~5 I
谢谢!
" u( B% v( Z# v; ^ |
|