|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序2 y0 d1 z0 ]- i7 g7 `+ B6 w
其中有一段如下
" e) y4 m: D+ J. O1 J' Rask turtles with [ infected? = true ]
- {9 X! U" P8 l; j' U3 H/ G# h我原本以为这句会回传『所有』infected? = true 的 turtle6 r- m/ B+ a! R' l1 X( @2 X+ V+ ?( }# ?
但看结果似乎不是这样。
4 O9 W2 I: y! Q& a- ?; B; f( G& o, W7 W, Y9 [6 d8 [+ {2 c r
假设所有符合条件的有 5 笔* p8 x' n2 T; o" S$ z9 V9 m7 J
有时候回传 1 笔,有时回传 3 笔,是不固定的1 o" i# d. c2 I1 }5 e
回头查语法定义
3 o3 U+ q* B! X8 b4 ]" B0 C' Vwith , q: g% T* B) R1 r( Q$ b/ L
agentset with [reporter]2 Y/ U4 f; x6 n1 n6 r3 W
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.
$ z M3 Q6 D# G9 J它只说回传 agents satisfying the given condition8 p+ X! W2 f8 k, O1 U* e
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 5 O, Z# X ]% j8 R
, R% t4 [6 w% b0 E- l! ^/ _3 w2 O" e想确定一下- Y. H, Q8 T0 X6 }* H; }
谢谢!) x3 z9 _( \. H
|
|