-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchapterFive.hs
64 lines (41 loc) · 984 Bytes
/
chapterFive.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
module ChapterFive where
data Mood = Blah | Woot deriving Show
changeMood :: Mood -> Mood
changeMood Woot = Blah
changeMood Blah = Woot
main :: IO ()
main = do
putStrLn ""
isPalindrome :: (Eq a) => [a] -> Bool
isPalindrome x = reverse x == x
myAbs :: Integer -> Integer
myAbs n = if n < 0 then (-1)*n else n
f :: (a, b) -> (c, d) -> ((b, d), (a, c))
f x y = ( (snd x, snd y), (fst x, fst y) )
x = (+)
zyx xs = x w 1
where w = length xs
imp :: a -> a -> a
imp x z = x
imp2 :: a -> b -> b
imp2 x y = y
functionH :: [a] -> a
functionH (x:_) = x
functionC :: (Ord a) => a -> a -> Bool
functionC x y = x > y
functionS :: (a, b) -> b
functionS (x, y) = y
i :: a -> a
i x = x
c :: a -> b -> a
c x y = x
c' :: a -> b -> b
c' x y = y
r :: [a] -> [a]
r (_:xs) = xs
co :: (b -> c) -> (a -> b) -> (a -> c)
co f g = f . g
a :: (a -> c) -> a -> a
a f x = x
a' :: (a -> b) -> a -> b
a' f = f