|
|
新手发问超简单问题,目前还处于研读范例码的阶段,边测边看结果来理解程序
: I; k; k( X3 j% D }其中有一段如下, c! A( h) X7 g# M
ask turtles with [ infected? = true ] ( q1 U% K* G `. |
我原本以为这句会回传『所有』infected? = true 的 turtle$ w+ @1 o3 i: x G, h! f
但看结果似乎不是这样。' T* x7 Y% Z' e1 E
9 a2 g. M( ~4 I0 [2 Q假设所有符合条件的有 5 笔5 S; I7 U0 u. _
有时候回传 1 笔,有时回传 3 笔,是不固定的3 Y3 [' g" @; _5 p" g6 q6 k9 ]1 P
回头查语法定义
: d# v1 P) W B" e4 C! iwith ! v: `$ c- v$ W
agentset with [reporter]% Y9 ?# ]) [) d
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.7 t3 p) z' }8 y9 c7 B' @
它只说回传 agents satisfying the given condition% L# f/ T, {: t8 K9 A9 A2 a
是否 with 回传的是『符合条件』的数据,而不是『所有符合条件』的数据 ?
% [$ @8 d* Y0 T3 N. v( O$ c" q
7 B( H3 ^. W; c" s4 @: |想确定一下5 h' k" b- j( q
谢谢!
2 u" g1 |" U4 N. W9 w5 T4 V+ J( Q, @ |
|