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

15 lines
311 B
Tcl

proc ordinal {n} {
if {$n%100<10 || $n%100>20} {
set suff [lindex {th st nd rd th th th th th th} [expr {$n % 10}]]
} else {
set suff th
}
return "$n'$suff"
}
foreach start {0 250 1000} {
for {set n $start; set l {}} {$n<=$start+25} {incr n} {
lappend l [ordinal $n]
}
puts $l
}