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.0.8.37 tracks/ocaml/exercises/say/example.ml
trackler-2.0.8.36 tracks/ocaml/exercises/say/example.ml
trackler-2.0.8.35 tracks/ocaml/exercises/say/example.ml
trackler-2.0.8.34 tracks/ocaml/exercises/say/example.ml
trackler-2.0.8.33 tracks/ocaml/exercises/say/example.ml
trackler-2.0.8.32 tracks/ocaml/exercises/say/example.ml
trackler-2.0.8.31 tracks/ocaml/exercises/say/example.ml
trackler-2.0.8.30 tracks/ocaml/exercises/say/example.ml
trackler-2.0.8.29 tracks/ocaml/exercises/say/example.ml
trackler-2.0.8.28 tracks/ocaml/exercises/say/example.ml
trackler-2.0.8.27 tracks/ocaml/exercises/say/example.ml
trackler-2.0.8.26 tracks/ocaml/exercises/say/example.ml
trackler-2.0.8.24 tracks/ocaml/exercises/say/example.ml
trackler-2.0.8.23 tracks/ocaml/exercises/say/example.ml
trackler-2.0.8.22 tracks/ocaml/exercises/say/example.ml
trackler-2.0.8.21 tracks/ocaml/exercises/say/example.ml
trackler-2.0.8.20 tracks/ocaml/exercises/say/example.ml
trackler-2.0.8.19 tracks/ocaml/exercises/say/example.ml
trackler-2.0.8.18 tracks/ocaml/exercises/say/example.ml
trackler-2.0.8.17 tracks/ocaml/exercises/say/example.ml