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.1 tracks/ocaml/exercises/say/example.ml
trackler-2.1.0.0 tracks/ocaml/exercises/say/example.ml
trackler-2.0.8.55 tracks/ocaml/exercises/say/example.ml
trackler-2.0.8.54 tracks/ocaml/exercises/say/example.ml
trackler-2.0.8.53 tracks/ocaml/exercises/say/example.ml
trackler-2.0.8.52 tracks/ocaml/exercises/say/example.ml
trackler-2.0.8.51 tracks/ocaml/exercises/say/example.ml
trackler-2.0.8.50 tracks/ocaml/exercises/say/example.ml
trackler-2.0.8.49 tracks/ocaml/exercises/say/example.ml
trackler-2.0.8.48 tracks/ocaml/exercises/say/example.ml
trackler-2.0.8.47 tracks/ocaml/exercises/say/example.ml
trackler-2.0.8.46 tracks/ocaml/exercises/say/example.ml
trackler-2.0.8.45 tracks/ocaml/exercises/say/example.ml
trackler-2.0.8.44 tracks/ocaml/exercises/say/example.ml
trackler-2.0.8.43 tracks/ocaml/exercises/say/example.ml
trackler-2.0.8.42 tracks/ocaml/exercises/say/example.ml
trackler-2.0.8.41 tracks/ocaml/exercises/say/example.ml
trackler-2.0.8.40 tracks/ocaml/exercises/say/example.ml
trackler-2.0.8.39 tracks/ocaml/exercises/say/example.ml
trackler-2.0.8.38 tracks/ocaml/exercises/say/example.ml