-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcurrying-and-uncurrying.hs
36 lines (24 loc) · 988 Bytes
/
currying-and-uncurrying.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
isTriangleTuple :: (Eq a, Num a) => (a, a, a) -> Bool
isTriangleTuple (alpha, beta, gamma) = alpha + beta + gamma == 180
-- isTriangle :: Double -> Double -> Double -> Bool
isTriangle :: (Eq a, Num a) => a -> a -> a -> Bool
isTriangle alpha beta gamma = alpha + beta + gamma == 180
-- mustBeSixty :: Double -> Bool
mustBeSixty :: Integer -> Bool
mustBeSixty = isTriangle 100 20
sumToNinety :: Integer -> Integer -> Bool
sumToNinety = isTriangle 90
dividesTuple :: (Int, Int) -> Bool
dividesTuple (a, b) = mod b a == 0
-- :t curry dividesTuple
divides :: Int -> Int -> Bool
divides a b = mod b a == 0
-- :t uncurry divides
divisibleByFour :: Int -> Bool
divisibleByFour = curry dividesTuple 4
inRange :: (Int, Int, Int) -> Bool
inRange(lower, upper, query) = lower <= query && query <= upper
inRangeCurried :: Int -> Int -> Int -> Bool
inRangeCurried lower upper query = inRange(lower, upper, query)
betweenTenAndTwenty :: Int -> Bool
betweenTenAndTwenty = inRangeCurried 10 20