Skip to content

Commit 88adb97

Browse files
author
Jani Rahkola
committed
Added exercise numbers to test docstrings.
1 parent f08d182 commit 88adb97

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed

test/recursion_test.clj

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,77 +6,77 @@
66
(and (sequential? x)
77
(clojure.core/empty? x)))
88

9-
(facts "product"
9+
(facts "ex 1 product"
1010
(product []) => 1
1111
(product [1 2 3]) => 6
1212
(product [1 2 3 4]) => 24
1313
(product [0 1 2]) => 0
1414
(product #{2 3 4}) => 24)
1515

16-
(facts "singleton?"
16+
(facts "ex 3 singleton?"
1717
(singleton? [1]) => true
1818
(singleton? #{2}) => true
1919
(singleton? []) => false
2020
(singleton? [1 2 3]) => false)
2121

22-
(facts "my-last"
22+
(facts "ex 4 my-last"
2323
(my-last []) => nil
2424
(my-last [1 2 3]) => 3
2525
(my-last [2 5]) => 5)
2626

27-
(facts "max-element"
27+
(facts "ex 5 max-element"
2828
(max-element [2 4 1 4]) => 4
2929
(max-element [2]) => 2
3030
(max-element []) => nil)
3131

32-
(facts "seq-max"
32+
(facts "ex 6 seq-max"
3333
(seq-max [1] [1 2]) => [1 2]
3434
(seq-max [1 2] [3 4]) => [3 4])
3535

36-
(facts "longest-sequence"
36+
(facts "ex 7 longest-sequence"
3737
(longest-sequence [[1 2] [] [1 2 3]]) => [1 2 3]
3838
(longest-sequence [[1 2]]) => [1 2]
3939
(longest-sequence []) => nil)
4040

41-
(facts "my-filter"
41+
(facts "ex 8 my-filter"
4242
(my-filter odd? [1 2 3 4]) => '(1 3)
4343
(my-filter (fn [x] (> x 9000)) [12 49 90 9001]) => '(9001)
4444
(my-filter even? [1 3 5 7]) => empty?)
4545

46-
(facts "sequence-contains?"
46+
(facts "ex 9 sequence-contains?"
4747
(sequence-contains? 3 [1 2 3]) => true
4848
(sequence-contains? 3 [4 7 9]) => false
4949
(sequence-contains? :pony []) => false)
5050

51-
(facts "my-take-while"
51+
(facts "ex 10 my-take-while"
5252
(my-take-while odd? [1 2 3 4]) => '(1)
5353
(my-take-while odd? [1 3 4 5]) => '(1 3)
5454
(my-take-while even? [1 3 4 5]) => empty?
5555
(my-take-while odd? []) => empty?)
5656

57-
(facts "my-drop-while"
57+
(facts "ex 11 my-drop-while"
5858
(my-drop-while odd? [1 2 3 4]) => '(2 3 4)
5959
(my-drop-while odd? [1 3 4 5]) => '(4 5)
6060
(my-drop-while even? [1 3 4 5]) => '(1 3 4 5)
6161
(my-drop-while odd? []) => empty?)
6262

63-
(facts "seq="
63+
(facts "ex 12 seq="
6464
(seq= [1 2 4] '(1 2 4)) => true
6565
(seq= [1 2 3] [1 2 3 4]) => false
6666
(seq= [1 3 5] []) => false)
6767

68-
(facts "my-map"
68+
(facts "ex 13 my-map"
6969
(my-map + [1 2 3] [4 4 4]) => '(5 6 7)
7070
(my-map + [1 2 3 4] [0 0 0]) => '(1 2 3)
7171
(my-map + [1 2 3] []) => empty?)
7272

73-
(facts "power"
73+
(facts "ex 14 power"
7474
(power 2 2) => 4
7575
(power 5 3) => 125
7676
(power 7 0) => 1
7777
(power 0 10) => 0)
7878

79-
(facts "fib"
79+
(facts "ex 15 fib"
8080
(fib 0) => 0
8181
(fib 1) => 1
8282
(fib 2) => 1
@@ -86,28 +86,28 @@
8686
(fib 6) => 8
8787
(fib 10) => 55)
8888

89-
(facts "my-repeat"
89+
(facts "ex 16 my-repeat"
9090
(my-repeat 2 :a) => '(:a :a)
9191
(my-repeat 3 "lol") => '("lol" "lol" "lol")
9292
(my-repeat -1 :a) => empty?)
9393

94-
(facts "my-range"
94+
(facts "ex 17 my-range"
9595
(my-range 0) => empty?
9696
(my-range 1) => '(0)
9797
(my-range 2) => '(1 0)
9898
(my-range 3) => '(2 1 0))
9999

100-
(facts "tails"
100+
(facts "ex 18 tails"
101101
(tails [1 2 3 4]) => (just [[1 2 3 4] [2 3 4] [3 4] [4] []] :in-any-order)
102102
(tails []) => (just [[]])
103103
(tails [1]) => (just [[1] []] :in-any-order))
104104

105-
(facts "inits"
105+
(facts "ex 18 inits"
106106
(inits [1 2 3 4]) => (just [[] [1] [1 2] [1 2 3] [1 2 3 4]] :in-any-order)
107107
(inits []) => (just [[]])
108108
(inits [1]) => (just [[] [1]] :in-any-order))
109109

110-
(facts "rotations"
110+
(facts "ex 19 rotations"
111111
(rotations []) => '(())
112112
(rotations [1 2 3]) => (just [[1 2 3] [2 3 1] [3 1 2]] :in-any-order)
113113
(rotations [:a :b]) => (just [[:a :b] [:b :a]] :in-any-order)
@@ -116,54 +116,54 @@
116116
:in-any-order)
117117
(count (rotations [6 5 8 9 2])) => 5)
118118

119-
(facts "my-frequencies"
119+
(facts "ex 20 my-frequencies"
120120
(my-frequencies []) => {}
121121
(my-frequencies [1 1 2 2 :D :D :D]) => {1 2, 2 2, :D 3}
122122
(my-frequencies [:a "moi" :a "moi" "moi" :a 1])
123123
=> {:a 3, "moi" 3, 1 1})
124124

125-
(facts "un-frequencies"
125+
(facts "ex 21 un-frequencies"
126126
(un-frequencies {:a 3 :b 2 "^_^" 1})
127127
=> (just [:a :a :a "^_^" :b :b] :in-any-order)
128128
(un-frequencies (my-frequencies [:a :b :c :a]))
129129
=> (just [:a :a :b :c] :in-any-order)
130130
(my-frequencies (un-frequencies {:a 100 :b 10}))
131131
=> {:a 100 :b 10})
132132

133-
(facts "my-take"
133+
(facts "ex 22 my-take"
134134
(my-take 2 [1 2 3 4]) => '(1 2)
135135
(my-take 4 [:a :b]) => '(:a :b))
136136

137-
(facts "my-drop"
137+
(facts "ex 23 my-drop"
138138
(my-drop 2 [1 2 3 4]) => '(3 4)
139139
(my-drop 4 [:a :b]) => empty?)
140140

141-
(facts "halve"
141+
(facts "ex 24 halve"
142142
(halve [1 2 3 4]) => ['(1 2) '(3 4)]
143143
(halve [1 2 3 4 5]) => ['(1 2) '(3 4 5)]
144144
(halve [1]) => (just empty? '(1)))
145145

146-
(facts "seq-merge"
146+
(facts "ex 25 seq-merge"
147147
(seq-merge [4] [1 2 6 7]) => '(1 2 4 6 7)
148148
(seq-merge [1 5 7 9] [2 2 8 10]) => '(1 2 2 5 7 8 9 10))
149149

150-
(facts "merge-sort"
150+
(facts "ex 26 merge-sort"
151151
(merge-sort []) => empty?
152152
(merge-sort [1 2 3]) => '(1 2 3)
153153
(merge-sort [5 3 4 17 2 100 1]) => '(1 2 3 4 5 17 100))
154154

155-
(facts "split-into-monotonics"
155+
(facts "ex 27 split-into-monotonics"
156156
(split-into-monotonics [0 1 2 1 0]) => '((0 1 2) (1 0))
157157
(split-into-monotonics [0 5 4 7 1 3]) => '((0 5) (4 7) (1 3)))
158158

159-
(facts "permutations"
159+
(facts "ex 28 permutations"
160160
(permutations []) => (just empty?)
161161
(count (permutations (range 5))) => 120
162162
(permutations [1 5 3])
163163
=> (just [1 5 3] [5 1 3] [5 3 1] [1 3 5] [3 1 5] [3 5 1]
164164
:in-any-order))
165165

166-
(facts "powerset"
166+
(facts "ex 29 powerset"
167167
(powerset []) => (some-checker (just empty?) (just #{#{}}))
168168
(powerset [1 2 4]) => (some-checker
169169
(just empty?

0 commit comments

Comments
 (0)