-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlec6.hs
More file actions
67 lines (43 loc) · 1.35 KB
/
lec6.hs
File metadata and controls
67 lines (43 loc) · 1.35 KB
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
map even [1..10]
filter even [1..10]
map (\s -> s ++ "fuck") ["I", "huh", "bitch"]
data Gender = Male | Female deriving (Show, Eq)
let people = [(Male, "Mal"), (Female, "Zoe"),
[(Male, "Wahs"), (Female, "Zzsoe"),
[(Male, "Jayne"), (Female, "Zfhoe"),
[(Male, "haal"), (Female, "Zodde")]
filter(\(a, b) -> a == Female) people
map snd it
foldl (+) 0 [1, 2, 3] --6
foldl (\acc n -> if n `elem` "aeiou"
then acc + 1
else acc) 0 "hello"
scanl (+) 0 [1, 2, 3] -- [0, 1, 3, 6] intermediate values of a fold
not (even 2)
not $ even 4
(not.even) 4
(length.last.words) "last man standing"
import Data.List
any (==0) [1,2,0] -- True
concat ["under", "stand", "able"]
sort "hello" -- "ehllo"
import Data.Char
toUpper 'a'
map ord ['a'..'f']
isNumber 'a'
import Data.map
let m = fromList[("I", "can do it myself"),
("this", "sucker dont know me"),
("Confident", "if you dont believe in yourself, who then?")]
keys m -- ["I", "this", "Confident"]
Data.Map.lookup "this" m
-- Just "sucker dont know me"
import Data.Set
let a = fromList [1..58]
let b = fromList [53..100]
intersection a b
findMax $ union a b
strong letters = length letters > 14
&& any isUpper letters
&& any isNumber letters
&& any isLower letters