|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序0 e5 U# e2 d9 h }0 O; U
其中有一段如下
3 m; {; K. \) U# E$ Task turtles with [ infected? = true ]
; K v. h- [5 @% i0 q我原本以为这句会回传『所有』infected? = true 的 turtle( Q# Y$ x1 E0 r. o, O
但看结果似乎不是这样。4 h: u9 G' s9 T6 a& R: w; U" y: _
% g3 D, s2 o* q+ h) A) T8 c
假设所有符合条件的有 5 笔2 ^! R3 u& V# h1 j U3 l% ^9 @
有时候回传 1 笔,有时回传 3 笔,是不固定的( _9 V/ @% X. t- ?- e3 @
回头查语法定义
) q# Q* [4 S2 C" Z vwith
7 M0 X) @- L% ]! b9 Magentset with [reporter]
, |0 Z) M# I+ K& f, cTakes 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 c+ S6 ~# i; X7 a
它只说回传 agents satisfying the given condition9 ~ G) G' s' ?+ C$ M( P D
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? - |1 \) q$ d" P0 x- S6 ?# @
6 o5 {9 k) v7 H7 {4 [9 K9 S
想确定一下
$ O5 O9 S) f+ g; L N$ r+ y, R谢谢!+ _8 A; U# z+ }7 D% q
|
|