Last active
November 6, 2015 14:58
-
-
Save zph/8c32c056d802e1bb3c9d to your computer and use it in GitHub Desktop.
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
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