-
Notifications
You must be signed in to change notification settings - Fork 0
/
20150319.hs
38 lines (34 loc) · 909 Bytes
/
20150319.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
double :: [Int] -> [Int]
double (a:as)
| as == [] = (a * 2:[])
| otherwise = (2*a:double as)
member :: [Int] -> Int -> Bool
member (a:as) number
| a == number = True
| as == [] = False
| otherwise = member as number
digits :: String -> String
digits [] = []
digits (a:as)
| a == '1' = (a:digits as)
| a == '2' = (a:digits as)
| a == '3' = (a:digits as)
| a == '4' = (a:digits as)
| a == '5' = (a:digits as)
| a == '6' = (a:digits as)
| a == '7' = (a:digits as)
| a == '8' = (a:digits as)
| a == '9' = (a:digits as)
| a == '0' = (a:digits as)
|otherwise = digits as
--digits :: String -> String
--digits (a:as)
-- | a >= '0' && a <= '9' && as == [] = (a:[])
-- | a >= '0' && a <= '9' = (a:digits as)
-- |otherwise = digits as
sumPairs :: [Int] -> [Int] -> [Int]
sumPairs (a:as) (b:bs)
| as == [] && bs == [] = (a+b:[])
| as == [] = bs
| bs == [] = as
| otherwise = (a+b: sumPairs as bs)