Sha256: 0fc2caa51ec531106f3492121b3eee690d1e62f3d2913c07075ed98fcbfb8ad5

Contents?: true

Size: 714 Bytes

Versions: 151

Compression:

Stored size: 714 Bytes

Contents

open Core

let bottles = function
    | 0 -> "no more bottles"
    | 1 -> "1 bottle"
    | n -> Int.to_string n ^ " bottles"

let line1 n =
    let b = bottles n in
    sprintf "%s of beer on the wall, %s of beer.\n" b b

let line2 n =
    sprintf "Take %s down and pass it around, %s of beer on the wall.\n"
            (if n > 0 then "one" else "it") (bottles n)

let verse = function
    | 0 -> String.capitalize (line1 0) ^
           "Go to the store and buy some more, 99 bottles of beer on the wall.\n"
    | n -> line1 n ^ line2 (n-1)

let lyrics ~from:from ~until:until =
    List.map (List.range ~stride:(-1) ~stop:`inclusive from until)
             ~f:(fun n -> verse n)
    |> String.concat ~sep:"\n"

Version data entries

151 entries across 151 versions & 1 rubygems

Version Path
trackler-2.2.1.50 tracks/ocaml/exercises/beer-song/example.ml
trackler-2.2.1.49 tracks/ocaml/exercises/beer-song/example.ml
trackler-2.2.1.48 tracks/ocaml/exercises/beer-song/example.ml
trackler-2.2.1.47 tracks/ocaml/exercises/beer-song/example.ml
trackler-2.2.1.46 tracks/ocaml/exercises/beer-song/example.ml
trackler-2.2.1.45 tracks/ocaml/exercises/beer-song/example.ml
trackler-2.2.1.44 tracks/ocaml/exercises/beer-song/example.ml
trackler-2.2.1.43 tracks/ocaml/exercises/beer-song/example.ml
trackler-2.2.1.42 tracks/ocaml/exercises/beer-song/example.ml
trackler-2.2.1.41 tracks/ocaml/exercises/beer-song/example.ml
trackler-2.2.1.40 tracks/ocaml/exercises/beer-song/example.ml
trackler-2.2.1.39 tracks/ocaml/exercises/beer-song/example.ml
trackler-2.2.1.38 tracks/ocaml/exercises/beer-song/example.ml
trackler-2.2.1.37 tracks/ocaml/exercises/beer-song/example.ml
trackler-2.2.1.36 tracks/ocaml/exercises/beer-song/example.ml
trackler-2.2.1.35 tracks/ocaml/exercises/beer-song/example.ml
trackler-2.2.1.34 tracks/ocaml/exercises/beer-song/example.ml
trackler-2.2.1.33 tracks/ocaml/exercises/beer-song/example.ml
trackler-2.2.1.32 tracks/ocaml/exercises/beer-song/example.ml
trackler-2.2.1.31 tracks/ocaml/exercises/beer-song/example.ml