From 3624c712d72d246f21d4e710cec7c11e052e0326 Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Tue, 9 Dec 2025 16:32:32 +0100 Subject: Add the haskell book --- Haskell-book/07/src/CasePractice.purs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Haskell-book/07/src/CasePractice.purs (limited to 'Haskell-book/07/src/CasePractice.purs') diff --git a/Haskell-book/07/src/CasePractice.purs b/Haskell-book/07/src/CasePractice.purs new file mode 100644 index 0000000..8f8cbab --- /dev/null +++ b/Haskell-book/07/src/CasePractice.purs @@ -0,0 +1,24 @@ +module CasePractice where + +import Data.Int (even) +import Prelude + +-- Exercise 1 +functionC :: forall a. Ord a => a -> a -> a +functionC x y = case (x > y) of + true -> x + false -> y + +-- Exercise 2 +isEvenAdd2 :: Int -> Int +isEvenAdd2 n = case even n of + true -> n + 2 + false -> n + +-- Exercise 3 +nums :: Int -> Int +nums x = + case compare x 0 of + LT -> -1 + GT -> 1 + EQ -> 0 -- cgit v1.2.3