-
Notifications
You must be signed in to change notification settings - Fork 0
/
collections.bhl
89 lines (75 loc) · 1.45 KB
/
collections.bhl
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
80
81
82
83
84
85
86
87
88
89
(doc list)
(list)
(list 1 2 "test")
(doc hash-set)
(hash-set)
(hash-set 1 2 "test" 1 "test")
(doc set)
(set)
(set (list 1 2 "test" 1 "test"))
(doc count)
(count false)
(count (list 1 2) 2)
(count nil)
(count (list))
(count (list 1 2 3))
(count [1 2 3])
(count (hash-set 1 2 "test" 1 "test"))
(count "test")
(doc first)
(first (list 1 2 3))
(first [1 2 3])
(first "test")
(first (hash-set 1 2 3))
(doc last)
(last (list 1 2 3))
(last "test")
(last (hash-set 1 2 3))
(doc nth)
(nth 5)
(nth 5 1)
(nth (list 1))
(nth (list 1) 1)
(nth (list 1) (- 1))
(nth (list 1) 0)
(nth (list 1 2 3) 1)
(nth "abc" 1)
(doc contains?)
(contains? (list 1 2 "test") "test")
(contains? (hash-set 1 2 "test" 1 "test") "test")
(contains? (hash-set) "xxx")
(contains? nil "xxx")
(doc conj)
(conj)
(conj 1)
(conj 1 1)
(conj 5 (list 1 2))
(conj 5 (list))
(conj 3 (hash-set 1 2))
(conj 3 (hash-set 1 2 3))
(conj 5 1)
(doc assoc)
(assoc (list 1 2 3) 1 "two")
(assoc (list 1 2 3) 3 "out of bounds")
(assoc nil 0 "zero")
(doc str)
(str)
(str nil)
(str 1 2 nil 3)
(str "hello" " " "world" "!")
(str "items: " (list 1 2 3))
(doc range)
(range)
(range 0 10 2)
(range "0" 10)
(range 0 10)
(doc reduce)
(reduce + (range 0 10))
(reduce + 100 (range 0 10))
(reduce (fn [acc x] (+ acc x)) (range 0 10))
(doc map)
(map inc [1 2 3 4 5])
(map (fn [x] (* x 10)) [1 2 3 4 5])
(map + [1 2 3] [4 5 6])
(map (fn [x] (str "Hello " x "!" )) ["Ford" "Arthur" "Tricia"])
(map list [1 2 3 4 5] ["a" "b" "c"] [0.4 0.9 0.2])