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.180 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.179 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.178 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.177 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.176 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.175 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.174 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.173 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.172 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.171 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.170 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.169 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.167 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.166 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.165 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.164 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.163 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.162 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.161 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.160 tracks/elixir/exercises/beer-song/example.exs