Sha256: 93da3b298d56b69fc3325e9862a19e9ff0bb191855e7256f468266b9b5693d22
Contents?: true
Size: 961 Bytes
Versions: 310
Compression:
Stored size: 961 Bytes
Contents
-module(example). -export([verse/1, sing/1, sing/2, test_version/0]). bottles(0) -> "no more bottles"; bottles(1) -> "1 bottle"; bottles(N) -> io_lib:format("~B bottles", [N]). -spec verse(non_neg_integer()) -> iolist(). verse(0) -> "No more bottles of beer on the wall, no more bottles of beer.\n" "Go to the store and buy some more, 99 bottles of beer on the wall.\n"; verse(1) -> "1 bottle of beer on the wall, 1 bottle of beer.\n" "Take it down and pass it around, no more bottles of beer on the wall.\n"; verse(N) -> io_lib:format( "~s of beer on the wall, ~s of beer.\n" "Take one down and pass it around, ~s of beer on the wall.\n", [bottles(N), bottles(N), bottles(N - 1)]). -spec sing(non_neg_integer()) -> iolist(). sing(N) -> sing(N, 0). -spec sing(non_neg_integer(), non_neg_integer()) -> iolist(). sing(From, To) -> lists:map(fun (N) -> [verse(N), "\n"] end, lists:seq(From, To, -1)). test_version() -> 1.
Version data entries
310 entries across 310 versions & 1 rubygems