Skip to content

Instantly share code, notes, and snippets.

@zph
Last active November 6, 2015 14:58
Show Gist options
  • Save zph/8c32c056d802e1bb3c9d to your computer and use it in GitHub Desktop.
Save zph/8c32c056d802e1bb3c9d to your computer and use it in GitHub Desktop.
module Main (main) where
import Html exposing (Html)
import Html.Attributes as Attributes
import String as S
fizz : Int -> Bool
fizz i = (0 == i % 3)
buzz : Int -> Bool
buzz i = (0 == i % 5)
intToFB : Int -> String
intToFB i =
let paddedNum = (S.padRight 4 ' ' (toString i)) in
let line txt = paddedNum ++ txt ++ "\n" in
case (fizz i, buzz i) of
(True, True) -> line "FizzBuzz"
(True, _) -> line "Fizz"
(_, True) -> line "Buzz"
(_, _) -> line ""
main : Html
main =
Html.pre
[Attributes.style [("margin", "10px")]]
(List.map (Html.text << intToFB) [1..100])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment