|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
]' v6 X' P% ]2 _: a其中有一段如下% P& v# P S8 W$ J8 V
ask turtles with [ infected? = true ] - O* d/ |. ~( b* ` s/ U! T2 [: h
我原本以为这句会回传『所有』infected? = true 的 turtle) z" W0 I* v, E" |5 t
但看结果似乎不是这样。- E' U/ w# D; s% @$ ?# ?1 M
- _! Y" s: W, {6 z" a
假设所有符合条件的有 5 笔! Z/ l& \- N' z( p! q. o `' S
有时候回传 1 笔,有时回传 3 笔,是不固定的
0 w" h) [! X' a回头查语法定义
# w6 F6 n) M# _5 u) A, Gwith
2 J- i' c, m, kagentset with [reporter]( g3 D9 U8 i K9 J) }
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.$ V% t* J: G% s3 h. @( f8 S$ A3 ?
它只说回传 agents satisfying the given condition
' m7 L5 \( X% D0 W U! L4 z/ z是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? 4 l) O% A/ T* L# U- U5 m7 \
; r' \- P$ e. m$ [: E想确定一下
% E9 y! Q1 q4 P5 Q* P谢谢!8 T* j- ]' G$ p8 f* y
|
|