From: simonpj Date: Fri, 24 May 2002 09:52:12 +0000 (+0000) Subject: [project @ 2002-05-24 09:52:12 by simonpj] X-Git-Tag: Approx_11550_changesets_converted~2017 X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=commitdiff_plain;h=7a3cd48aa8d547883b3fc156b4325293a1a87add [project @ 2002-05-24 09:52:12 by simonpj] speakNth works for 11,12,13 --- diff --git a/ghc/compiler/utils/Outputable.lhs b/ghc/compiler/utils/Outputable.lhs index b3e515d..2be035c 100644 --- a/ghc/compiler/utils/Outputable.lhs +++ b/ghc/compiler/utils/Outputable.lhs @@ -425,14 +425,15 @@ speakNth 3 = ptext SLIT("third") speakNth 4 = ptext SLIT("fourth") speakNth 5 = ptext SLIT("fifth") speakNth 6 = ptext SLIT("sixth") -speakNth n = hcat [ int n, text st_nd_rd_th ] +speakNth n = hcat [ int n, text suffix ] where - st_nd_rd_th | n_rem_10 == 1 = "st" - | n_rem_10 == 2 = "nd" - | n_rem_10 == 3 = "rd" - | otherwise = "th" + suffix | n <= 20 = "th" -- 11,12,13 are non-std + | last_dig == 1 = "st" + | last_dig == 2 = "nd" + | last_dig == 3 = "rd" + | otherwise = "th" - n_rem_10 = n `rem` 10 + last_dig = n `rem` 10 \end{code} \begin{code}