|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
$ |& B9 K: R( ]9 C其中有一段如下
# V2 g, \- n7 X# }$ g. Q# j1 rask turtles with [ infected? = true ] l- O \' X! v, ?; b" Q& P4 y6 H
我原本以为这句会回传『所有』infected? = true 的 turtle
* a0 G r" [9 [6 F& D但看结果似乎不是这样。' }5 F# P' _8 F1 ?
0 f" H" f8 d$ E( {5 h, Y假设所有符合条件的有 5 笔7 m" \/ E; ^) h9 w$ e4 K
有时候回传 1 笔,有时回传 3 笔,是不固定的
4 u( H9 W2 P3 {' `9 O) m& @回头查语法定义- M" R& m: D5 n2 R, S; ?. b# Q! h
with . O" G6 n$ D9 E: L8 n* u
agentset with [reporter]. w9 u; ~: y) q: }6 [
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.3 c9 o' k N, A, v+ Z. E
它只说回传 agents satisfying the given condition
" K5 E. d5 {5 {是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
- u, V: ]3 l5 l- S( q5 q1 J- h1 [5 v4 v0 C6 C7 a$ r, h
想确定一下' c- |/ d- \9 y/ T' O
谢谢!
9 p5 g2 ], o9 d4 V2 J; q) n2 v3 L |
|