From 97277bf91c6ce903dc3844843b2350b41a1cfa72 Mon Sep 17 00:00:00 2001 From: Shritesh Bhattarai Date: Tue, 27 Feb 2018 09:35:08 -0600 Subject: [PATCH] @shritesh's solution for Idris School --- shritesh+idris/.gitignore | 1 + shritesh+idris/FizzBuzz.idr | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 shritesh+idris/.gitignore create mode 100644 shritesh+idris/FizzBuzz.idr diff --git a/shritesh+idris/.gitignore b/shritesh+idris/.gitignore new file mode 100644 index 0000000..563996e --- /dev/null +++ b/shritesh+idris/.gitignore @@ -0,0 +1 @@ +*.ibc diff --git a/shritesh+idris/FizzBuzz.idr b/shritesh+idris/FizzBuzz.idr new file mode 100644 index 0000000..26dba76 --- /dev/null +++ b/shritesh+idris/FizzBuzz.idr @@ -0,0 +1,16 @@ +fizz_buzz : Nat -> List String +fizz_buzz num = + map fb [1..num] +where + fb : Nat -> String + fb n = if mod n 15 == 0 then + "FizzBuzz" + else if mod n 3 == 0 then + "Fizz" + else if mod n 5 == 0 then + "Buzz" + else + show n + +main : IO () +main = repl "\n> " (\num => unwords (fizz_buzz (cast num))) \ No newline at end of file