RosettaCodeData/Task/Look-and-say-sequence/Sather/look-and-say-sequence.sa
2023-07-01 13:44:08 -04:00

27 lines
575 B
Text

class MAIN is
look_and_say!: STR is
current ::= "1";
loop
yield current;
buf ::= #FSTR;
last ::= current[0];
count ::= 0;
loop
ch ::= current.elt!;
if ch /= last then
buf := buf + count + last;
last := ch; count := 1;
else
count := count + 1;
end;
end;
current := (buf + count + last).str;
end;
end;
main is
loop 12.times!;
#OUT+ look_and_say! + "\n";
end;
end;
end;