|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
* g/ ^' V7 o: G, H3 q. a其中有一段如下; x+ a; Y# M9 K }$ S
ask turtles with [ infected? = true ] : B: C- U+ P7 x1 b
我原本以为这句会回传『所有』infected? = true 的 turtle/ b8 X7 a9 ?9 U9 y' d" l
但看结果似乎不是这样。9 Y, E4 r) ~( y" k _
0 Q M+ S+ {3 N假设所有符合条件的有 5 笔
! a& i" b+ g. ?有时候回传 1 笔,有时回传 3 笔,是不固定的7 m$ u, \" y7 }3 d' J
回头查语法定义
/ p8 }: ?+ j3 G7 ]; R2 y9 A) O& nwith
! n* B7 b: |/ ?. U @. Iagentset with [reporter]
# k; e5 G8 V! _/ i5 PTakes 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.
: |0 P/ I- U* h$ A! {它只说回传 agents satisfying the given condition
7 F) t- N2 ^$ e. p是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? + d6 K# @3 h- C7 O' }, x' h; _
; I" s1 y9 D4 F, g# x# z
想确定一下+ }' _/ e/ J& g' M2 r
谢谢!' \' u2 ^9 L. ~' V# n
|
|