|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序" z" p" l$ d! k# {1 @& q& D& s
其中有一段如下
" y( n o8 }8 j8 |ask turtles with [ infected? = true ]
) ?: Q4 ~" K$ B我原本以为这句会回传『所有』infected? = true 的 turtle
. l/ d, l, F. D. R& c4 x但看结果似乎不是这样。
4 q0 Q1 `$ h) L/ ^& v6 E- T; g' K- [- A. `6 e& ] R2 Z4 V
假设所有符合条件的有 5 笔
; R+ w8 V4 I$ f) i Y3 k有时候回传 1 笔,有时回传 3 笔,是不固定的
$ S& }. q4 W+ M6 Y% Y/ H. ]回头查语法定义
0 s, T$ R8 ] Zwith 6 s J- |# R; Q; z
agentset with [reporter]
9 g3 U N2 f/ |4 \ R" @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.
) p3 `3 f- C: V3 S0 E' d它只说回传 agents satisfying the given condition
" O5 l& L* s2 X5 N& B是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
% f5 ?( V' x C( I2 X
! b+ @0 u' b" G想确定一下
4 K7 R8 T9 N, ]: y! T谢谢!
# s4 a- _/ J/ ]# ~ |
|