|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序1 K% P: n7 ~- ^; m7 i
其中有一段如下
% _* T& V9 Z! b3 Q, Lask turtles with [ infected? = true ] 1 w" S+ P$ A- \" R* G* ]) v% Y4 s
我原本以为这句会回传『所有』infected? = true 的 turtle
1 n; ?, f/ p7 N% r! a5 F4 m2 U" w$ C但看结果似乎不是这样。! Z2 K4 Y0 y, ^/ Q r
5 {0 B% |' k7 t& \假设所有符合条件的有 5 笔
$ K9 O" a. W$ ^; E: ?有时候回传 1 笔,有时回传 3 笔,是不固定的
% s9 B' z/ T5 p+ D% D回头查语法定义
" o9 X; k$ x" }) G; r9 Lwith
; H8 w0 U/ \# _3 ^6 _agentset with [reporter]
$ Z, v) J w! Z4 y, ]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.3 d0 t, T; ~0 S' A' [2 i
它只说回传 agents satisfying the given condition4 @+ Z( E3 l& i
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
7 s( b: P; j7 C- h) S, ^( F# Z8 M$ V8 T$ @) o! F; U l7 C
想确定一下
! I7 I8 L y& S1 N& _谢谢!
; y0 z- q+ i* Y$ W# G- C, J |
|