23 lines
403 B
Text
23 lines
403 B
Text
vardef lookandsay(expr s) =
|
|
string r; r := "";
|
|
if string s:
|
|
i := 0;
|
|
forever: exitif not (i < length(s));
|
|
c := i+1;
|
|
forever: exitif ( (substring(c,c+1) of s) <> (substring(i,i+1) of s) );
|
|
c := c + 1;
|
|
endfor
|
|
r := r & decimal (c-i) & substring(i,i+1) of s;
|
|
i := c;
|
|
endfor
|
|
fi
|
|
r
|
|
enddef;
|
|
|
|
string p; p := "1";
|
|
for el := 1 upto 10:
|
|
message p;
|
|
p := lookandsay(p);
|
|
endfor
|
|
|
|
end
|