|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序 _! c+ g; ]! g: I' ~8 F7 a
其中有一段如下8 w% r- E' q! _+ a2 g+ G3 }
ask turtles with [ infected? = true ] . M2 w% z' b. v0 j
我原本以为这句会回传『所有』infected? = true 的 turtle
8 a) V: X' k5 i5 S# _) c: s但看结果似乎不是这样。. Q# X: Z8 u6 ~; G2 l# C
9 u. m0 i) C7 [. u9 t) D4 z3 A假设所有符合条件的有 5 笔
4 M, G/ K% K" i/ x& ~有时候回传 1 笔,有时回传 3 笔,是不固定的
7 ?5 |! G3 B9 R5 M; Z回头查语法定义
) t. F% K( R$ \with
- U0 W' N3 i1 G6 L( A, Y3 A2 j6 l, dagentset with [reporter]( e+ k7 m6 j& M3 b$ u
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.$ f$ C. V3 P! ^& F; p
它只说回传 agents satisfying the given condition* T' {; T% s' _. S
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
/ D0 N. V( a5 G, k7 j4 I; U! {* U" [$ ^ l( L0 X. q
想确定一下
k* I" R2 {! S5 A, b4 h5 I谢谢!
6 _& r) T5 [( g# r2 Q! C |
|