We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a1f268b commit fa8ca4eCopy full SHA for fa8ca4e
philharvey+idris/fizzbuzz.ibc
4.19 KB
philharvey+idris/fizzbuzz.idr
@@ -1,18 +1,11 @@
1
module Main
2
3
-isFizz : Nat -> Bool
4
-isFizz n = modNat n 3 == 0
5
-
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 ++ ", "))
+fizzbuzz s n = if isFizz n then s ++ "Fizz\n" else
+ if isBuzz n then s ++ "Buzz\n" else s ++ show n ++ "\n"
+ where isFizz n = modNat n 3 == 0
+ isBuzz n = modNat n 5 == 0
16
17
main : IO ()
18
-main = putStrLn $ foldl fizzbuzz "" [1..100]
+main = do
+ putStrLn $ foldl fizzbuzz "" [1..100]
0 commit comments