|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
7 S* f; N& U& }) ]$ T其中有一段如下
6 X, C4 y. ]% E. Eask turtles with [ infected? = true ] / T' d7 C9 t2 V0 Z1 Y7 }0 }5 A8 ]" v
我原本以为这句会回传『所有』infected? = true 的 turtle
& d5 @ q) p! ^但看结果似乎不是这样。
3 n0 _2 x% e" {% X) T% [; c1 G0 H# Y4 y' k
假设所有符合条件的有 5 笔
; e; }# o5 J( T# R3 x有时候回传 1 笔,有时回传 3 笔,是不固定的2 U h x5 O7 b6 b1 \1 n3 K/ l
回头查语法定义
3 ]# `+ A% X2 h: O u& Ewith
* ?* E8 L+ r) ?, i) `: kagentset with [reporter]' X4 E4 V% _9 }& z/ m- `
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.$ l: v# _$ J m9 J
它只说回传 agents satisfying the given condition
$ j+ W B) y1 K& }: |是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
( Q) H, l# A' z9 N
. R# A6 w! w( L& G/ E; L想确定一下
- L& B. Z. @) \& ~( w& D& P9 f谢谢!9 Q+ }( d2 b7 T6 s; [2 w0 w
|
|