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.2.1.109 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.108 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.107 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.106 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.105 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.104 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.103 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.102 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.101 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.100 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.99 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.98 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.97 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.96 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.95 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.94 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.93 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.92 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.91 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.90 tracks/elixir/exercises/beer-song/example.exs