|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序2 H3 g, q& d* @7 j# Z" M
其中有一段如下
1 n$ z! U7 l% Nask turtles with [ infected? = true ] 6 W8 R) l* ~& E) |! k2 C; V/ ^
我原本以为这句会回传『所有』infected? = true 的 turtle
! P( y' J0 G: H但看结果似乎不是这样。
- C) L! _) |7 {8 i. S ~; ~' j- h
2 _8 E% }! j3 X2 N假设所有符合条件的有 5 笔
; A9 }5 N3 ]5 u有时候回传 1 笔,有时回传 3 笔,是不固定的
$ l2 i4 ^/ E6 n9 @/ P, \) e; K回头查语法定义
% X) z4 O0 \# ~) ]" D/ Iwith + t2 H, F' f4 h0 Q) V, d
agentset with [reporter]& z* ]/ A+ `9 D- a3 ~. X
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.
7 i' V; ?0 S8 s它只说回传 agents satisfying the given condition. P! `7 _# [- ~ Q5 [( m
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
* Z/ E# n! B+ O6 q2 g& n, o6 K
; j, S* e* z0 F8 f; P想确定一下, J! @1 g' d2 W- X& Y
谢谢!" S" ~, ~9 O2 E0 P9 p- R
|
|