Last active
February 18, 2016 11:37
-
-
Save yurrriq/58dc75be826ebaebee53 to your computer and use it in GitHub Desktop.
FizzBuzz in LFE
This file contains 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
(defmodule fizzbuzz | |
(export (fizzbuzz 1))) | |
(defun fizzbuzz (n) | |
(lists:foreach | |
(lambda (x) (lfe_io:format "~p~n" `(,x))) | |
(lists:map #'fizz/1 (lists:seq 1 n)))) | |
(defun fizz (n) (fizz n (rem n 3) (rem n 5))) | |
(defun fizz | |
([_ 0 0] 'FizzBuzz) | |
([_ 0 _] 'Fizz) | |
([_ _ 0] 'Buzz) | |
([n _ _] n)) |
Author
yurrriq
commented
Aug 17, 2015
> (fizzbuzz 15)
1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz
ok
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment