|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序 U; ^2 F1 f8 Z& _9 S3 f
其中有一段如下
# |) z" ~$ u3 v; D: Task turtles with [ infected? = true ] - \1 e2 E; ?' w1 c
我原本以为这句会回传『所有』infected? = true 的 turtle
5 \9 H5 ~* s. l8 z. n4 ^* a但看结果似乎不是这样。
2 P- u) a6 @1 M& ]( g
* [4 u4 |* ^( y+ u0 A假设所有符合条件的有 5 笔
, c8 A* F H) _( R4 p有时候回传 1 笔,有时回传 3 笔,是不固定的
$ }+ {: k) i: [; L回头查语法定义
5 P! T& l$ @3 M/ @( z" o/ D) mwith , @, k) s4 d5 J4 O0 [2 D3 J
agentset with [reporter]) \/ Z4 P& j1 `
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.- {4 c- M9 ] T! i
它只说回传 agents satisfying the given condition) a8 F5 v% Z7 g
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
; W6 Y1 {# O8 T; ~! p
2 k0 @, H" A8 _/ N想确定一下7 I, W( M( D# \8 R8 N1 W
谢谢!
2 u6 i5 y5 H( \# Q" v. |" { |
|