Skip to content

Instantly share code, notes, and snippets.

@bitmappergit
Created April 21, 2019 22:39
Show Gist options
  • Save bitmappergit/c1c657df9e7c994cfb2b07d37538207d to your computer and use it in GitHub Desktop.
Save bitmappergit/c1c657df9e7c994cfb2b07d37538207d to your computer and use it in GitHub Desktop.
-module(lambda).
-export([beer/0]).
beer() ->
Fun =
fun
BeerFun(N) when N =:= 0 ->
io:format("No more bottles of beer on the wall, no more bottles of beer.~n"),
io:format("Go to the store and buy some more, 99 bottles of beer on the wall.~n~n");
BeerFun(N) when N =:= 1 ->
io:format("1 bottle of beer on the wall, 1 bottle of beer.~n"),
io:format("Take it down, and pass it around, no more bottles of beer on the wall.~n~n"),
BeerFun(N - 1);
BeerFun(N) ->
io:format("~w bottles of beer on the wall, ~w bottles of beer.~n", [N,N]),
io:format("Take one down, and pass it around, ~w bottles of beer on the wall.~n~n", [N]),
BeerFun(N - 1)
end,
(Fun)(99).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment