|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序$ ?, @1 A* ]" V4 Q* k2 D, r. B
其中有一段如下
) t9 s$ y) |. hask turtles with [ infected? = true ] # `0 }& }. ?* W8 C" M4 K
我原本以为这句会回传『所有』infected? = true 的 turtle
5 {, G3 W# q' e5 I% ]; q" L但看结果似乎不是这样。+ G: ], r4 G$ S. d$ W
+ H0 ^" v" |3 ?$ u" t
假设所有符合条件的有 5 笔5 q7 J& @1 ^, s6 {
有时候回传 1 笔,有时回传 3 笔,是不固定的. _, p# q- Q: Q3 N& Q! S
回头查语法定义. {- e+ b; X$ A: F) m
with 7 m( q. j' A. d3 V# v& W6 v! D, [
agentset with [reporter]7 B$ `( X; I5 f+ a1 m- a s
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.
- }: [; B- I. W它只说回传 agents satisfying the given condition8 j2 o" p. |9 U, ]- W$ K; [1 W8 ~
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
; w! o, F9 m, c- n. V% P
; n- b/ I% e) B想确定一下
; h: ]2 }6 f: y' i+ v; t谢谢!- \4 g. ^3 Y0 N. W0 J; A
|
|