|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序" h# H0 C1 o. S ^" W3 g8 {3 V6 W
其中有一段如下
4 z. N' D* z& C' Uask turtles with [ infected? = true ] / F: S/ L; a2 r6 f
我原本以为这句会回传『所有』infected? = true 的 turtle9 ^1 S6 T2 \" z
但看结果似乎不是这样。
/ C5 w7 f+ c' I4 z& `: @- p$ N& W6 U& B# B
假设所有符合条件的有 5 笔, J5 \2 R; _/ b
有时候回传 1 笔,有时回传 3 笔,是不固定的' T. k8 J9 V; y, {2 `' K
回头查语法定义: p6 F5 z+ i0 y+ D2 F& l6 ^
with " M+ c- \- U7 C' @
agentset with [reporter]
3 R( |7 }) U. [) I7 wTakes 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." Q( n5 q9 v+ k5 F
它只说回传 agents satisfying the given condition2 p" A. |- W) ]& G' Y" U8 |
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? , O5 u. X2 y/ r8 k7 G Y+ N
' S% u# z& V# ~ H# L
想确定一下- E0 O0 |: H3 T# b; |7 F6 G- G
谢谢!4 Y$ g8 Q* \5 x0 x! o2 n- v2 x" e
|
|