Last active
May 6, 2016 12:11
-
-
Save ctran/2ba31e45343a6281f0bf to your computer and use it in GitHub Desktop.
Fizz Buzz in elm
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
import Graphics.Element (Element, flow, down) | |
import List (map) | |
import Text (asText) | |
main : Element | |
main = | |
let fizzBuzz n = case (n % 3, n % 5) of | |
(0, 0) -> "FizzBuzz" | |
(0, _) -> "Fizz" | |
(_, 0) -> "Buzz" | |
_ -> toString n | |
in map fizzBuzz [1..100] |> map asText |> flow down |
You inspired me to write a dynamic version of fizzBuzz. I am sure it can be improved. Let me know what you think.
https://github.com/kgisl/project-ideas/blob/master/elm/fizzBuzz.elm
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice code! Made some changes to compile under latest Elm release - https://gist.github.com/kgashok/ff4f7e06dacd30febf901efd820e58bf