|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
: i+ i: ^- k6 e/ Z' k) F4 g0 S' e其中有一段如下
. a4 x& e0 e$ l% `ask turtles with [ infected? = true ] $ B5 d2 O: n" {( k$ |6 I8 ~; s, L
我原本以为这句会回传『所有』infected? = true 的 turtle+ B& a) x/ b. W8 w8 c+ w9 N1 j
但看结果似乎不是这样。
2 o. l& Q: _4 ^0 y
; z5 w% W& B" Y! ^( C' |假设所有符合条件的有 5 笔
! ]8 @: k% L$ Y; S$ c1 T2 g2 i有时候回传 1 笔,有时回传 3 笔,是不固定的
1 K8 b9 S* ], ^" }+ w- Q+ E回头查语法定义
: `7 W$ d8 t' j6 k* K3 Owith
1 p/ A/ a4 Z! \$ fagentset with [reporter]* {3 ?6 I" z# H5 i3 U& g& W- c
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" |5 R. d+ b& W/ y. p4 y它只说回传 agents satisfying the given condition
" ]0 N7 D3 U. J# t* L是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
' `8 Q. X( i9 K9 e4 A* i
& `# {9 `6 S; V3 ?& b5 ]' K想确定一下
8 l% \9 U3 x! E7 N谢谢!/ O3 V1 H, t% q" A- y4 U: }9 r
|
|