Sha256: aae442622832a6eaae43a3d001c2da537e64ba19f78533bd0c97213bb0fd28fe

Contents?: true

Size: 1.44 KB

Versions: 68

Compression:

Stored size: 1.44 KB

Contents

open Base

let rec in_english_impl = let open Int64 in function
  | 0L -> "zero"
  | 1L -> "one"
  | 2L -> "two"
  | 3L -> "three"
  | 4L -> "four"
  | 5L -> "five"
  | 6L -> "six"
  | 7L -> "seven"
  | 8L -> "eight"
  | 9L -> "nine"
  | 10L -> "ten"
  | 11L -> "eleven"
  | 12L -> "twelve"
  | 13L -> "thirteen"
  | 14L -> "fourteen"
  | 15L -> "fifteen"
  | 16L -> "sixteen"
  | 17L -> "seventeen"
  | 18L -> "eighteen"
  | 19L -> "nineteen"
  | 20L -> "twenty"
  | 30L -> "thirty"
  | 40L -> "forty"
  | 50L -> "fifty"
  | 60L -> "sixty"
  | 70L -> "seventy"
  | 80L -> "eighty"
  | 90L -> "ninety"
  | n when n <= 99L ->
     in_english_impl (10L * (n / 10L)) ^ "-" ^ in_english_impl (n % 10L)
  | n when n <= 999L ->
     in_english_impl (n / 100L) ^ " hundred" ^
       let rem = n % 100L in
       if rem = 0L then "" else " " ^ in_english_impl rem
  | n when n <= 999_999L ->
     in_english_impl (n / 1_000L) ^ " thousand" ^
       let rem = n % 1_000L in
       if rem = 0L then "" else " " ^ in_english_impl rem
  | n when n <= 999_999_999L ->
     in_english_impl (n / 1_000_000L) ^ " million" ^
       let rem = n % 1_000_000L in
       if rem = 0L then "" else " " ^ in_english_impl rem
  | n ->
     in_english_impl (n / 1_000_000_000L) ^ " billion" ^
       let rem = n % 1_000_000_000L in
       if rem = 0L then "" else " " ^ in_english_impl rem

let in_english n =
  if Int64.(n < 0L || n >= 1_000_000_000_000L) then None else Some (in_english_impl n)

Version data entries

68 entries across 68 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/ocaml/exercises/say/example.ml
trackler-2.2.1.179 tracks/ocaml/exercises/say/example.ml
trackler-2.2.1.178 tracks/ocaml/exercises/say/example.ml
trackler-2.2.1.177 tracks/ocaml/exercises/say/example.ml
trackler-2.2.1.176 tracks/ocaml/exercises/say/example.ml
trackler-2.2.1.175 tracks/ocaml/exercises/say/example.ml
trackler-2.2.1.174 tracks/ocaml/exercises/say/example.ml
trackler-2.2.1.173 tracks/ocaml/exercises/say/example.ml
trackler-2.2.1.172 tracks/ocaml/exercises/say/example.ml
trackler-2.2.1.171 tracks/ocaml/exercises/say/example.ml
trackler-2.2.1.170 tracks/ocaml/exercises/say/example.ml
trackler-2.2.1.169 tracks/ocaml/exercises/say/example.ml
trackler-2.2.1.167 tracks/ocaml/exercises/say/example.ml
trackler-2.2.1.166 tracks/ocaml/exercises/say/example.ml
trackler-2.2.1.165 tracks/ocaml/exercises/say/example.ml
trackler-2.2.1.164 tracks/ocaml/exercises/say/example.ml
trackler-2.2.1.163 tracks/ocaml/exercises/say/example.ml
trackler-2.2.1.162 tracks/ocaml/exercises/say/example.ml
trackler-2.2.1.161 tracks/ocaml/exercises/say/example.ml
trackler-2.2.1.160 tracks/ocaml/exercises/say/example.ml