RosettaCodeData/Task/Nth/Draco/nth.draco
2023-07-01 13:44:08 -04:00

32 lines
676 B
Text

proc nonrec nth(word n; *char buf) *char:
channel output text ch;
open(ch, buf);
write(ch; n,
if (n/10)%10=1 then "th"
elif n%10=1 then "st"
elif n%10=2 then "nd"
elif n%10=3 then "rd"
else "th"
fi
);
close(ch);
buf
corp;
proc nonrec print_range(word start, stop) void:
[8] char buf;
word col, n;
col := 0;
for n from start upto stop do
write(nth(n, &buf[0]));
col := col + 1;
if col%10=0 then writeln() else write('\t') fi
od;
writeln()
corp
proc nonrec main() void:
print_range(0, 25);
print_range(250, 265);
print_range(1000, 1025)
corp