Sha256: eaeb64eeb4d5c2afe84dc77c51b32db8ae8db78c38fd10fa682a63a507bbfdab

Contents?: true

Size: 772 Bytes

Versions: 250

Compression:

Stored size: 772 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

250 entries across 250 versions & 1 rubygems

Version Path
trackler-2.0.6.31 tracks/elixir/exercises/beer-song/example.exs
trackler-2.0.6.30 tracks/elixir/exercises/beer-song/example.exs
trackler-2.0.6.29 tracks/elixir/exercises/beer-song/example.exs
trackler-2.0.6.28 tracks/elixir/exercises/beer-song/example.exs
trackler-2.0.6.27 tracks/elixir/exercises/beer-song/example.exs
trackler-2.0.6.26 tracks/elixir/exercises/beer-song/example.exs
trackler-2.0.6.25 tracks/elixir/exercises/beer-song/example.exs
trackler-2.0.6.24 tracks/elixir/exercises/beer-song/example.exs
trackler-2.0.6.23 tracks/elixir/exercises/beer-song/example.exs
trackler-2.0.6.22 tracks/elixir/exercises/beer-song/example.exs