|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序4 E$ I( [2 e% t7 Z7 r
其中有一段如下
5 ^9 s4 ^$ a! k, [6 w9 z+ S. lask turtles with [ infected? = true ] $ w; S% m0 [9 V/ r4 v
我原本以为这句会回传『所有』infected? = true 的 turtle
) U6 Y( R5 |" `5 z/ \但看结果似乎不是这样。
. N* h2 }1 T! T
a$ h% ?' W$ a9 c, d, A假设所有符合条件的有 5 笔4 O S5 a0 W& Z7 o( {* g
有时候回传 1 笔,有时回传 3 笔,是不固定的) R5 G3 S% M. ?" U* ^+ S
回头查语法定义
% O" q( j. J- q* _5 b! Q/ K) z# `with
8 u5 f; b( f9 K: {agentset with [reporter]0 _6 J g5 U `; W3 ~
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.
4 V2 u& S5 F! p3 I8 \6 L它只说回传 agents satisfying the given condition/ x6 b. z- ^) S" K" ~) a. [
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? " s- U" h' ?% k# h
4 a# p! j' T) X Q
想确定一下
! b& c& g7 I3 T4 w( @+ y谢谢!
5 B3 h' z5 m) ]2 s/ \3 D6 n |
|