aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/pp.ml
diff options
context:
space:
mode:
authorGravatar Pierre-Marie Pédrot <pierre-marie.pedrot@inria.fr>2015-02-26 14:31:25 +0100
committerGravatar Pierre-Marie Pédrot <pierre-marie.pedrot@inria.fr>2015-02-26 14:38:09 +0100
commit15a3b57db10e61c9de12b5880b04b46db1494b5b (patch)
tree7c1f64ab00de98e7b23ac8a88b74a57a614c2470 /lib/pp.ml
parentf712a0523359d5b54b4d4160bc77271fdde094a3 (diff)
Fixing printing of ordinals.
Diffstat (limited to 'lib/pp.ml')
-rw-r--r--lib/pp.ml11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/pp.ml b/lib/pp.ml
index cc56e5e8d..76046a7f9 100644
--- a/lib/pp.ml
+++ b/lib/pp.ml
@@ -517,8 +517,17 @@ let pr_arg pr x = spc () ++ pr x
let pr_opt pr = function None -> mt () | Some x -> pr_arg pr x
let pr_opt_no_spc pr = function None -> mt () | Some x -> pr x
+(** TODO: merge with CString.ordinal *)
let pr_nth n =
- int n ++ str (match n mod 10 with 1 -> "st" | 2 -> "nd" | 3 -> "rd" | _ -> "th")
+ let s =
+ if (n / 10) mod 10 = 1 then "th"
+ else match n mod 10 with
+ | 1 -> "st"
+ | 2 -> "nd"
+ | 3 -> "rd"
+ | _ -> "th"
+ in
+ int n ++ str s
(* [prlist pr [a ; ... ; c]] outputs [pr a ++ ... ++ pr c] *)