Skip to content

Instantly share code, notes, and snippets.

@ctran
Last active May 6, 2016 12:11
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ctran/2ba31e45343a6281f0bf to your computer and use it in GitHub Desktop.
Save ctran/2ba31e45343a6281f0bf to your computer and use it in GitHub Desktop.
Fizz Buzz in elm
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
@kgashok
Copy link

kgashok commented May 6, 2016

Nice code! Made some changes to compile under latest Elm release - https://gist.github.com/kgashok/ff4f7e06dacd30febf901efd820e58bf

@kgashok
Copy link

kgashok commented May 6, 2016

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