|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
5 \8 _' L; x# e# D其中有一段如下9 g1 b# t/ S0 Y8 ?% _& P/ ]
ask turtles with [ infected? = true ] 8 |% N: @- a& \0 G3 N8 u% c- D& f
我原本以为这句会回传『所有』infected? = true 的 turtle) B7 l% x/ @7 b" U& B2 M: u: p
但看结果似乎不是这样。& c9 }. @3 G! n! W5 g/ x
9 @7 d0 x* I$ C# T( H$ y2 M假设所有符合条件的有 5 笔( n- s, u x- h
有时候回传 1 笔,有时回传 3 笔,是不固定的/ B! s9 V- k- m0 D0 N
回头查语法定义# m% `0 g: n+ f3 U
with
: J2 L5 W2 T# X2 ]1 b( W1 Zagentset with [reporter]
6 Q4 q; }# \0 B- I lTakes 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.
" I! @ Q# S" r `, e1 R9 u2 m它只说回传 agents satisfying the given condition5 ~9 _7 [2 s& f, Q C m
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
+ d1 f) I% V" }: f( V F
3 o; w8 X2 b3 s( z. x, N) u想确定一下
/ U- M1 _# z, a& b9 T) g谢谢!
! M' W; e4 X6 ?& {7 M |
|