我写的这个计算语句,调试时通过,但是运行时出现了不知名的错误5 y/ U2 F2 ?- o& _# J. Y( M9 K8 o# @
请达人帮我指出错误好改进! h) a$ j0 j/ d6 x4 z) a4 n
% O% @6 O5 ]1 p$ u6 b7 E& Z* S4 Pto find-distance
* u. p! f) ?, A: D8 j6 \! o K) Z- V let i 0
' j% E7 c, L+ {1 ]; W let nodedistance 0
/ v- `$ p3 ~# J! U" P let linknumber 0, M2 ^2 U1 [8 k8 [/ K2 M* N
while [i < count turtles]
/ J' t8 [& U6 f. C1 o [
- A& R: P0 Y. [7 v K9 T6 B if link-neighbor? turtle i* F: C! Q7 B& n* [8 D3 r
[set nodedistance (nodedistance + sum ([link-length] of turtle i))4 U% o5 E4 {2 l& g4 }# `0 f
set linknumber (linknumber + count [link-neighbors] of turtle i)]& V/ ^: S/ U$ ]7 l( K; Y0 {4 Z
if linknumber != 0
0 {& ]" m8 X$ `1 R/ h7 C& Z [
9 T1 L! q" u% R: v- E6 A( y2 j set average-node-distance (nodedistance / linknumber)
1 d* F9 l' [, x- Z ] A% C# f: c, J; h
set i i + 1
: d& u$ F' y$ _+ _% {/ W ]; P/ A3 X) H- a$ I+ f
end/ c. U1 A; w6 I1 Y5 c) Q
/ t1 y" F& e+ H
[ 本帖最后由 qy987 于 2008-11-12 02:18 编辑 ] |