|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
0 W8 _8 [; f5 y/ H# Q! e6 I2 u其中有一段如下! u( n( g" }7 U: J
ask turtles with [ infected? = true ] ! S% E* t/ W1 r @: h- P
我原本以为这句会回传『所有』infected? = true 的 turtle
/ ^0 K) w, a3 w* J4 o. J2 ?' w但看结果似乎不是这样。
J5 @7 I: C2 L4 g* q
6 q3 a0 e9 Q( M' o4 i! F8 r假设所有符合条件的有 5 笔' l Y* d ]' r7 z+ `
有时候回传 1 笔,有时回传 3 笔,是不固定的
( i8 H/ u, i7 Z/ p# E回头查语法定义, |/ W0 b1 T: W9 p4 ]& I. S
with
# L2 d( o) c* ]6 W5 magentset with [reporter]; F( H+ Q7 c& O! T. l( v
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 C! Y3 a+ V T M它只说回传 agents satisfying the given condition
% r* {# I$ u! {+ O9 S是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ? - m) O. U) t& b
2 i$ q5 |. k" W. G! o( o想确定一下9 K' \: K2 \$ N) y- E b
谢谢!+ g$ n" {3 Y2 f% X, O; Q
|
|