File tree Expand file tree Collapse file tree 2 files changed +10
-13
lines changed
Expand file tree Collapse file tree 2 files changed +10
-13
lines changed Original file line number Diff line number Diff line change 11module Main
22
3- isFizz : Nat -> Bool
4- isFizz n = modNat n 3 == 0
3+ mapToFizzBuzz : Nat -> String
4+ mapToFizzBuzz n = if isFizz n && isBuzz n then " FizzBuzz" else
5+ if isFizz n then " Fizz" else
6+ if isBuzz n then " Buzz" else show n
7+ where isFizz n = modNat n 3 == 0
8+ isBuzz n = modNat n 5 == 0
59
6- isBuzz : Nat -> Bool
7- isBuzz n = modNat n 5 == 0
8-
9- isFizzBuzz : Nat -> Bool
10- isFizzBuzz n = modNat n 15 == 0
11-
12- fizzbuzz : String -> Nat -> String
13- fizzbuzz s n = if isFizzBuzz n then s ++ " Fizz Buzz, " else
14- (if isFizz n then s ++ " Fizz, " else
15- (if isBuzz n then s ++ " Buzz, " else s ++ show n ++ " , " ))
10+ reduceFizzBuzz : String -> Nat -> String
11+ reduceFizzBuzz s n = s ++ mapToFizzBuzz n ++ " \n "
1612
1713main : IO ()
18- main = putStrLn $ foldl fizzbuzz " " [1 .. 100 ]
14+ main = do
15+ putStrLn $ foldl reduceFizzBuzz " " [1 .. 100 ]
You can’t perform that action at this time.
0 commit comments