-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhw3.hs
76 lines (52 loc) · 1.26 KB
/
hw3.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
64
65
66
67
68
69
70
71
72
73
74
75
76
-- e1
-- safetail xs = if null xs then [] else tail xs
-- safetail [] = []
-- safetail (_ : xs) = xs
-- safetail xs
-- | null xs = []
-- | otherwise = tail xs
-- safetail [] = []
-- safetail xs = tail xs
safetail
= \ xs ->
case xs of
[] -> []
(_ : xs) -> xs
-- e2
-- import Prelude hiding ((||))
-- False || False = False
-- _ || _ = True
-- False || b = b
-- True || _ = True
-- b || c
-- | b == c = b
-- | otherwise = True
-- b || False = b
-- _ || True = True
-- b || c
-- | b == c = c
-- | otherwise = True
-- b || True = b
-- _ || True = True
False || False = False
False || True = True
True || False = True
True || True = True
-- e3
-- import Prelude hiding ((&&))
-- True && True = True
-- _ && _ = False
-- a && b = if a then if b then True else False else False
-- a && b = if a then b else False
-- a && b = if b then a else False
-- a && b = if not (a) then not (b) else True
-- a && b = if a then b
-- a && b = if a then if b then False else True else False
-- e4
-- mult x y z = \ x -> (\ y -> (\ z -> x * y * z))
-- mult = \ x -> (\ y -> (\ z -> x * y * x))
-- mult = \ x -> (x * \ y -> (y * \ z -> z))
-- mult = ((((\x -> \y) -> \z) -> x * y) * z)
-- e8
funct :: Int -> [a] -> [a]
funct x xs = take (x + 1) xs ++ drop x xs