|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
- e! c( f, t9 _( S! ?) d M2 C. k其中有一段如下
5 g6 a2 X9 s q" `ask turtles with [ infected? = true ] ' ~$ e" R) C. E3 a
我原本以为这句会回传『所有』infected? = true 的 turtle
" N( [5 K5 A* k4 ?& p2 a' n但看结果似乎不是这样。
1 v/ F# v% K# e% E2 ]
+ A6 O) L# ?6 C" ]/ K假设所有符合条件的有 5 笔
4 F9 [* g# S5 V8 Y. N7 g有时候回传 1 笔,有时回传 3 笔,是不固定的8 `4 Z u% {+ u' t( s% k+ |) x$ Q
回头查语法定义
; e O; Z8 i& P/ k# Vwith
' f3 Z+ q* @- Z+ D% jagentset with [reporter]+ `1 ?+ I8 _1 h# u$ 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.( O' \% I) Y7 `* B, r" b2 i0 W
它只说回传 agents satisfying the given condition
V* g* n2 q5 o" z' d7 w( ]3 Q4 f是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? $ `9 u1 ?1 J) n* V! H9 A+ E- ]
4 j" K. ]! [0 g; ]% ~6 W4 o" H想确定一下
/ l5 A P) h c谢谢!
P4 U. j, N1 ^( C2 p. ~5 E' U |
|