Last active
May 16, 2017 14:38
-
-
Save sovetnik/f61b0e15740b12bde5c6f6d4c2a44017 to your computer and use it in GitHub Desktop.
FizzBuzz in Erlang
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(fb). | |
-export([run/0, run/1, tell/1]). | |
run() -> lists:map(fun(L) -> io:format('~p ~n', [tell(L)]) end, lists:seq(1,100)). | |
run(N) -> lists:map(fun(L) -> io:format('~p ~n', [tell(L)]) end, lists:seq(1,N)). | |
tell(N) when N rem 15 == 0 -> 'FizzBuzz'; | |
tell(N) when N rem 3 == 0 -> 'Fizz'; | |
tell(N) when N rem 5 == 0 -> 'Buzz'; | |
tell(N) when is_integer(N) -> N; | |
tell(_) -> 'Fuck this'. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment