-
Notifications
You must be signed in to change notification settings - Fork 0
/
20150428.txt
79 lines (67 loc) · 2.38 KB
/
20150428.txt
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
77
78
79
-- TRABALHO 10
-- A. foldr (+).(.).map
----------------------------------------------------------------------------------------------------
-- B. (\x y z -> foldr z x y).map
foldr :: (t -> u -> u) -> u -> [t] -> u
(.) :: (t -> v) -> (u -> t) -> u -> v
map :: (t-> b) -> [t] -> [b]
(\x y z -> foldr z x y).map :
(\x y z -> foldr z x y)
x = u
z = (t -> u -> u)
y = [t]
(\x y z -> foldr z x y) = (u -> [t] -> (t -> u -> u) -> u)
(u -> t) = map
u = (x -> b)
t = [x] -> [b]
(t -> v) = (u -> [t] -> (t -> u -> u) -> u)
t = u
v = [t] -> (t -> u -> u) -> u
t = [x] -> [b] => v = [t] -> (t -> ([x] -> [b]) -> ([x] -> [b])) -> [x] -> [b]
(u -> v): (x -> b) -> [t] -> (t -> ([x] -> [b]) -> ([x] -> [b])) -> [x] -> [b]
(\x y z -> foldr z x y).map = (x -> b) -> [t] -> (t -> ([x] -> [b]) -> ([x] -> [b])) -> [x] -> [b]
----------------------------------------------------------------------------------------------------
-- C. map.((.) (foldr (++) (foldr (++) [] [[1], [2]])))
map.((.) (foldr (++) (foldr (++) [] [[1], [2]])))
map.((.) (foldr (++) [1,2]))
map :: (a -> b) -> [a] -> [b]
(.) :: (d -> e) -> (c -> d) -> c -> e
(.) :: (g -> h) -> (f -> g) -> f -> h
foldr :: (i -> j -> j) -> j -> [i] -> j
(++) :: [k] -> [k] -> [k]
(foldr (++) [1,2]) => ([k] -> [k] -> [k]) -> [k] -> [[k]] -> [k]
(foldr (++) [1,2]) => [[k]] -> [k]
((.) (foldr (++) [1,2])) => ([[k]] -> [k]) -> (u -> [[k]]) -> u -> [k]
((.) (foldr (++) [1,2])) => (u -> [[k]]) -> u -> [k]
c -> d = (u -> [[k]]) -> u -> [k] = ((.) (foldr (++) [1,2]))
c = (u -> [[k]])
d = (u -> [k])
d -> e = (a -> b) -> [a] -> [b] = map
d = (a -> b)
e = [a] -> [b]
d = (u -> [k]) = (a -> b) => a = u && [k] = b
e = [u] -> [[k]]
c -> e = (u -> [[k]]) -> [u] -> [[k]]
map.((.) (foldr (++) [1,2])) = (u -> [[k]]) -> [u] -> [[k]]
----------------------------------------------------------------------------------------------------
-- D. (foldr).(.)$(!!)
(foldr).(.)$(!!)
(!!):: [t] -> Int ->t
(.):: (t -> v) -> (u -> t) -> u -> v
foldr:: (t -> u -> u) -> u -> [t] -> u
(foldr).(.):
(.) = u1 -> t1
u1 = (t -> v)
t1 = (u -> t) -> u -> v
foldr = t1 -> v1
t1 = (t -> u -> u)
v1 = (u -> [t] -> u)
(u2 -> t2) -> u2 -> v2 = (t -> u -> u) => t = (u2 -> t2) && u2 = u = v2
t1 = ((u2 -> t2) -> u2 -> u2)
v1 = (u2 -> [u2 -> t2] -> u2)
u1 = (t2 -> u2)
(foldr).(.) = (t2 -> u2) -> u2 -> [u2 -> t2] -> u2
(t2->u2) = !!
t2 = [t3]
u2 = (Int -> t3)
(foldr).(.)$(!!) = (Int -> t3) -> [(Int -> t3) -> [t3]] -> Int -> t3