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.159 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.158 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.157 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.156 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.155 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.154 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.153 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.152 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.151 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.150 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.149 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.148 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.147 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.146 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.145 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.144 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.143 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.142 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.141 tracks/elixir/exercises/beer-song/example.exs
trackler-2.2.1.140 tracks/elixir/exercises/beer-song/example.exs