Sha256: f5d4feba1203d369de04bb036899865547e6686fd47b27a05c1dfc23309fee9a

Contents?: true

Size: 780 Bytes

Versions: 69

Compression:

Stored size: 780 Bytes

Contents

defmodule BeerSong do
  def verse(0) do
    "No more bottles of beer on the wall, no more bottles of beer.\nGo to the store and buy some more, 99 bottles of beer on the wall.\n"
  end

  def verse(1) do
    "1 bottle of beer on the wall, 1 bottle of beer.\nTake it down and pass it around, no more bottles of beer on the wall.\n"
  end

  def verse(2) do
    "2 bottles of beer on the wall, 2 bottles of beer.\nTake one down and pass it around, 1 bottle of beer on the wall.\n"
  end

  def verse(number) do
    "#{number} bottles of beer on the wall, #{number} bottles of beer.\nTake one down and pass it around, #{
      number - 1
    } bottles of beer on the wall.\n"
  end

  def lyrics(range \\ 99..0) do
    range
    |> Enum.map(&verse/1)
    |> Enum.join("\n")
  end
end

Version data entries

69 entries across 69 versions & 1 rubygems

Version Path
trackler-2.2.1.119 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.118 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.117 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.116 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.115 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.114 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.113 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.111 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.110 tracks/elixir/exercises/beer-song/example.exs