Sha256: 61c6e982162513b9aa7a06c308e7a61b2430f5836b1e45e9629e367f17148de3

Contents?: true

Size: 1.43 KB

Versions: 176

Compression:

Stored size: 1.43 KB

Contents

open Core.Std

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 n < 0L || n >= 1_000_000_000_000L then None else Some (in_english_impl n)

Version data entries

176 entries across 176 versions & 1 rubygems

Version Path
trackler-2.1.0.21 tracks/ocaml/exercises/say/example.ml
trackler-2.1.0.20 tracks/ocaml/exercises/say/example.ml
trackler-2.1.0.19 tracks/ocaml/exercises/say/example.ml
trackler-2.1.0.18 tracks/ocaml/exercises/say/example.ml
trackler-2.1.0.17 tracks/ocaml/exercises/say/example.ml
trackler-2.1.0.16 tracks/ocaml/exercises/say/example.ml
trackler-2.1.0.15 tracks/ocaml/exercises/say/example.ml
trackler-2.1.0.14 tracks/ocaml/exercises/say/example.ml
trackler-2.1.0.13 tracks/ocaml/exercises/say/example.ml
trackler-2.1.0.12 tracks/ocaml/exercises/say/example.ml
trackler-2.1.0.11 tracks/ocaml/exercises/say/example.ml
trackler-2.1.0.10 tracks/ocaml/exercises/say/example.ml
trackler-2.1.0.9 tracks/ocaml/exercises/say/example.ml
trackler-2.1.0.8 tracks/ocaml/exercises/say/example.ml
trackler-2.1.0.7 tracks/ocaml/exercises/say/example.ml
trackler-2.1.0.6 tracks/ocaml/exercises/say/example.ml
trackler-2.1.0.5 tracks/ocaml/exercises/say/example.ml
trackler-2.1.0.4 tracks/ocaml/exercises/say/example.ml
trackler-2.1.0.3 tracks/ocaml/exercises/say/example.ml
trackler-2.1.0.2 tracks/ocaml/exercises/say/example.ml