|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序& e& E, ]# [0 \
其中有一段如下
5 w, R$ O7 H- r, \9 ]ask turtles with [ infected? = true ] ( n. H+ G& R" j* S
我原本以为这句会回传『所有』infected? = true 的 turtle7 P' d6 ]% U2 z3 R. ~
但看结果似乎不是这样。( j6 f8 J t; I+ X: T
8 @2 ]/ ` I# F0 H8 |& @0 Q3 F假设所有符合条件的有 5 笔5 f% x8 T3 q& z/ D) [0 w
有时候回传 1 笔,有时回传 3 笔,是不固定的
. o4 ^. |2 Y+ n; k3 u( ^0 H* t回头查语法定义
1 E4 n6 I l. h. l2 a3 k' Swith
6 u0 z; J* C3 a3 p+ T( v! Q, Fagentset with [reporter]8 J- F# ^# g" z5 L. {/ H6 r- I2 ]
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.
8 R, h7 x/ t) _4 E它只说回传 agents satisfying the given condition) t( d1 L% ]7 O; d0 N9 [
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
/ A% k- ~+ h, }# n
( g3 U* L: K' A; ]- ]想确定一下7 `0 {3 A( O4 p4 s# {0 @
谢谢!
# O$ q! ?: ]% W t6 v9 _1 K% U5 z |
|