|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序% v4 Y9 ]3 Q. Y7 V
其中有一段如下
) I/ ~9 _; d( P4 O/ Z1 l5 i5 _ask turtles with [ infected? = true ]
/ Q: g4 y+ {; E4 ^8 Z- R我原本以为这句会回传『所有』infected? = true 的 turtle7 G t# G/ L$ M. q; C, x6 L. Y
但看结果似乎不是这样。
; ^* y9 }9 k# l
0 R/ Q m( c1 p假设所有符合条件的有 5 笔! U# y) i% i. v5 p; Q& ^) {5 p
有时候回传 1 笔,有时回传 3 笔,是不固定的6 o: ]8 a Z+ `
回头查语法定义
1 t* a z( ?# z3 d, p% Q7 _" ]with 1 K# K8 U7 Z: `
agentset with [reporter]/ Y4 ^3 }4 e: b. |0 v# }6 g6 r
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.5 c# C, I, { O' O! I1 ]
它只说回传 agents satisfying the given condition
/ u+ C# o% T3 E7 E; Y是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
0 ^0 [# x3 {! X/ U$ e5 r" {; U
! j/ v# q8 o, e% v. {0 J7 k$ h; [想确定一下
2 p/ W1 o% E P+ o谢谢!: r" A8 m; ^! Q4 i% Y7 X8 M
|
|