|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序$ O' O2 k( c+ j2 |6 @+ F8 j$ g3 p
其中有一段如下
6 X3 M0 z2 j# \8 x7 xask turtles with [ infected? = true ]
+ Z# t5 ]* n9 A" g( m1 E# g) e我原本以为这句会回传『所有』infected? = true 的 turtle2 Q1 q8 P: a; r1 `4 A& J0 m
但看结果似乎不是这样。
6 J% i) Y; \- \% s
; [6 w+ R* @3 n假设所有符合条件的有 5 笔- B9 H8 a( t5 |9 [: U
有时候回传 1 笔,有时回传 3 笔,是不固定的. u% |% B. p# n2 J
回头查语法定义
2 F/ _. e& E! F) i0 J# @! z9 uwith
2 Y. W6 y5 n" i$ Aagentset with [reporter]
! A$ m9 K9 C% `0 K: j9 V, @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.: s, E* [) v; Y1 W# ^5 o7 W9 {
它只说回传 agents satisfying the given condition! J) `, _' F+ @# o
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 2 W; W) \" ?4 i u2 q! }
! p' f% F# m+ T. P3 {) r
想确定一下
6 V: S. l+ h1 L. i* N' m$ J6 F; o& d谢谢!
0 \/ A- c% C- A. _ |
|