|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序0 _/ f: N( U" ?
其中有一段如下
1 C; ~9 W4 Q3 r) ~# v! Hask turtles with [ infected? = true ] : s2 [: T1 o: P" C9 C. U/ O+ m
我原本以为这句会回传『所有』infected? = true 的 turtle
5 ^1 H- i+ h. Z( F* P, [" Q但看结果似乎不是这样。1 k% I% U0 Z0 d. M8 m
- K7 h1 |6 U' T# C假设所有符合条件的有 5 笔
0 l' I! A! |8 q9 q/ `% b1 \7 }有时候回传 1 笔,有时回传 3 笔,是不固定的
5 X/ }' ]9 j% h* k5 S3 [回头查语法定义
1 Y3 o u( u9 ^' d& @" X& Ewith * w" Q& E' j4 S" X5 v
agentset with [reporter], [, N$ t9 }; |& ~/ O4 E
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.
" [0 Z$ r" Z* s: s+ N$ s它只说回传 agents satisfying the given condition6 l( o- E+ y- ~: ^
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? - _3 D! }9 O2 n# p2 P9 U, @
, x! _7 T$ m! [! E2 K0 V2 t& u
想确定一下
4 E8 ^4 m! i& E. }2 v谢谢!
# r) L f z \5 I8 E7 b& X |
|