inspect应该不是这么用的,不知道你要解决什么问题,如果是要本程序内判断ci的大小,用if-else就可以了。如果ci不是本程序的,需要调用此程序时,可以用inspect,用法如下: ' P- S% c" V" V7 h4 F" s(number : integer)4 V! L3 r. _7 Q) v; A
is$ @3 o: J2 y0 H( K+ r. I
do / Z O C3 M3 {) i. H3 Z" e inspect number 7 y5 |5 h; E& U: b. D3 ?& t% B when 1 then # [ a) J+ e1 h print "not a prime number"5 N; U, P3 {8 c! E* u; H
when 2,5,7,3 then * G( O2 g1 @7 P5 I# ~2 U print "prime number" 3 H; W2 _' d2 x5 q1 L9 C9 M. [3 m- d when 9,4 then ; \4 `9 d. W6 T7 E4 B print "square number"3 k% I' I/ \7 W3 t' V; u
else+ g6 V8 x9 b0 g7 z4 a
print "no special number";/ I2 s w$ n8 |" \$ W8 {, S
print "or number greater than 9"; : f: c. T- z% }$ t2 y end; ! _7 i- [7 U, }% y5 nend;