]> gitweb.factorcode.org Git - factor.git/commitdiff
math.text.english: adding some ap-style number conversions.
authorJohn Benediktsson <mrjbq7@gmail.com>
Fri, 19 Mar 2021 18:17:53 +0000 (11:17 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Fri, 19 Mar 2021 18:17:53 +0000 (11:17 -0700)
extra/math/text/english/english.factor

index 0de9903d360212136a2b8ec5e7823a3b57668355..41374474121336550e7ffe4eef59b51432775713 100644 (file)
@@ -122,3 +122,15 @@ M: complex number>text
             [ drop "th" ]
         } case
     ] if ;
+
+: number-ap-style ( n -- str )
+    dup { [ integer? ] [ 0 9 between? ] } 1&&
+    [ number>text ] [ number>string ] if ;
+
+: ordinal-ap-style ( n -- str )
+    dup {
+        f "first" "second" "third" "fourth" "fifth" "sixth"
+        "seventh" "eighth" "ninth"
+    } ?nth [ nip ] [
+        [ number>string ] [ ordinal-suffix ] bi append
+    ] if* ;