-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathch5.hs
69 lines (43 loc) · 1.2 KB
/
ch5.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
module Ch5 where
import Data.List
f :: a -> a -> a -> a
f = undefined
x :: Char; x = undefined
wbReverse :: Foldable t => t a -> [a]
wbReverse = \xs -> foldl (flip(:)) [] xs
anyEven = any even [1,2..]
prefix xs ys = and (zipWith (==) xs ys)
fibs = 0 : 1 : zipWith (+) fibs (tail fibs)
wbMin :: Ord c => [c] -> c
wbMin = \xs -> (head . sort) xs
myMin :: Ord c => [c] -> c
myMin = \xs -> head $ sort xs
i :: a -> a
i = id
c :: a -> b -> a
c = \a -> \b -> fst (a, b)
c' :: a -> b -> b
c' = \a -> \b -> snd (a, b)
r :: [a] -> [a]
r = tail
co :: (b -> c) -> (a -> b) -> (a -> c)
co = (.)
a :: (a -> c) -> a -> a
a = \g -> \a -> snd (g a, a)
a' :: (a -> b) -> a -> b
a' = \g -> \a -> g a
p :: IO ()
p = do
print $ 1 + 2
putStrLn "10"
print (negate (-1))
print ((+) 0 blah)
where blah = negate 1
fa :: Int -> String
fa = undefined
ga :: String -> Char
ga = undefined
ha :: Int -> Char
ha = \i -> (.) ga fa i -- ga $ fa i; (ga . fa) i
munge :: (x -> y) -> (y -> (w, z)) -> x -> w
munge = \f -> \g -> \a -> fst $ g $ f a -- (fst . g . f) a