Skip to content

Instantly share code, notes, and snippets.

@stoft
Last active November 15, 2015 20:49
Show Gist options
  • Save stoft/44c5ebd1ed89914127fa to your computer and use it in GitHub Desktop.
Save stoft/44c5ebd1ed89914127fa to your computer and use it in GitHub Desktop.
FizzBuzz in Elm
import Graphics.Element exposing (show)
main = show (iterate 100)
fizzbuzz : Int -> String
fizzbuzz n =
if | mod n 15 -> "FizzBuzz"
| mod n 5 -> "Buzz"
| mod n 3 -> "Fizz"
| otherwise -> toString n
mod : Int -> Int -> Bool
mod i j =
i % j == 0
iterate : Int -> List String
iterate max =
List.map fizzbuzz [1 .. max]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment