summaryrefslogtreecommitdiff
path: root/Haskell-book/07/src/CasePractice.purs
blob: 8f8cbab6b3a2d9725547f9cb0943391f7ca5a435 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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