From 7a3cd48aa8d547883b3fc156b4325293a1a87add Mon Sep 17 00:00:00 2001 From: simonpj Date: Fri, 24 May 2002 09:52:12 +0000 Subject: [PATCH] [project @ 2002-05-24 09:52:12 by simonpj] speakNth works for 11,12,13 --- ghc/compiler/utils/Outputable.lhs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) 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} -- 1.7.10.4