Skip to content

Commit 0585f3c

Browse files
committed
chore: remove deprecated math:even, math:odd, dict:contains, dict:size, list:size
1 parent 6996ee7 commit 0585f3c

File tree

7 files changed

+30
-75
lines changed

7 files changed

+30
-75
lines changed

Dict.ark

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,6 @@
3333
# @author https://github.com/SuperFola
3434
(let contains? (fun (_D _key) (builtin__dict:contains _D _key)))
3535

36-
# @brief Checks if the dictionary has a given key
37-
# @deprecated Use `dict:contains?`
38-
# @param _D dictionary
39-
# =begin
40-
# (let data (dict "key" "value"))
41-
# (print (dict:contains data "key")) # true
42-
# (print (dict:contains data "test")) # false
43-
# =end
44-
# @author https://github.com/SuperFola
45-
(let contains contains?)
46-
4736
# @brief Get a value from a given dictionary using a key, or a default value if it doesn't exist
4837
# @param _D dictionary
4938
# @param _key key to get
@@ -55,7 +44,7 @@
5544
# =end
5645
# @author https://github.com/SuperFola
5746
(let getOrElse (fun (_D _key _default)
58-
(if (contains _D _key)
47+
(if (contains? _D _key)
5948
(get _D _key)
6049
_default)))
6150

@@ -71,7 +60,7 @@
7160
# =end
7261
# @author https://github.com/SuperFola
7362
(let updateOrDefault (fun (_D _key _f _default)
74-
(if (contains _D _key)
63+
(if (contains? _D _key)
7564
(add _D _key (_f (get _D _key)))
7665
(add _D _key _default))))
7766

@@ -97,16 +86,6 @@
9786
# @author https://github.com/SuperFola
9887
(let keys (fun (_D) (builtin__dict:keys _D)))
9988

100-
# @brief Computes the number of (key, value) pairs in a given dictionary
101-
# @param _D dictionary
102-
# @deprecated Use the builtin `len` instead
103-
# =begin
104-
# (let data (dict "key" "value"))
105-
# (print (dict:size data)) # 1
106-
# =end
107-
# @author https://github.com/SuperFola
108-
(let size (fun (_D) (builtin__dict:size _D)))
109-
11089
# @brief Returns a list of the values of a dictionary
11190
# @param _D dictionary
11291
# =begin

List.ark

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,6 @@
5959
# @author https://github.com/SuperFola
6060
(let fill (fun (_count _val) (builtin__list:fill _count _val)))
6161

62-
# @brief Function to call the `len` operator on a list
63-
# @param _L list to get the size of
64-
# @deprecated Use the builtin `len` instead
65-
# =begin
66-
# (print (list:size [1 2 3 4])) # 4
67-
# =end
68-
# @author https://github.com/SuperFola
69-
(let size (fun (_L) (len _L)))
70-
7162
# @brief Modify a given list and return a new one
7263
# @details The original list is not modified
7364
# @param list the list to modify

Math.ark

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -171,23 +171,11 @@
171171
# @author https://github.com/rstefanic
172172
(let even? (fun (_n) (= 0 (mod _n 2))))
173173

174-
# @brief Return true if the number is even, false otherwise
175-
# @deprecated Use `math:even?`
176-
# @param _n the number
177-
# @author https://github.com/rstefanic
178-
(let even even?)
179-
180174
# @brief Return true if the number is odd, false otherwise
181175
# @param _n the number
182176
# @author https://github.com/rstefanic
183177
(let odd? (fun (_n) (= 1 (abs (mod _n 2)))))
184178

185-
# @brief Return true if the number is odd, false otherwise
186-
# @deprecated Use `math:odd?`
187-
# @param _n the number
188-
# @author https://github.com/rstefanic
189-
(let odd odd?)
190-
191179
# @brief Get the minimum between two numbers
192180
# @param _a the first number
193181
# @param _b the second number

tests/dict-tests.ark

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,11 @@
6363
(test:expect (not (dict:contains? d "hello")))
6464
(test:expect (not (dict:contains? d d))) })
6565

66-
(test:case "size" {
67-
(test:eq (dict:size d) 6)
68-
(test:eq (dict:size d) (len d))
69-
(test:eq (dict:size (dict)) 0)
70-
(test:eq (dict:size (dict)) (len (dict)))
71-
(test:eq (dict:size d3) 1)
72-
(test:eq (dict:size d3) (len d3))
73-
(test:eq (dict:size d4) 1) })
66+
(test:case "len" {
67+
(test:eq (len d) 6)
68+
(test:eq (len (dict)) 0)
69+
(test:eq (len d3) 1)
70+
(test:eq (len d4) 1) })
7471

7572
(test:case "keys" {
7673
(test:eq (dict:keys d) ["key" 5 true false foo closure])
@@ -104,14 +101,14 @@
104101
(test:eq (dict:get d5 "count") 2) })
105102

106103
(test:case "remove" {
107-
(test:eq (dict:size d) 7)
104+
(test:eq (len d) 7)
108105
(dict:remove d "test")
109106
(test:eq (dict:get d "test") nil)
110-
(test:eq (dict:size d) 6) })
107+
(test:eq (len d) 6) })
111108

112109
(test:case "map" {
113110
(let mapped (dict:map d2 map_to_str))
114-
(test:eq (dict:size d2) (dict:size mapped))
111+
(test:eq (len d2) (len mapped))
115112
(test:eq (dict:get d2 "a") 1)
116113
(test:eq (dict:get d2 "b") 2)
117114
(test:eq (dict:get d2 "c") 3)
@@ -120,11 +117,11 @@
120117
(test:eq (dict:get mapped "c") "3")
121118

122119
(let mapped2 (dict:map (dict) (fun (k v) v)))
123-
(test:eq (dict:size mapped2) 0) })
120+
(test:eq (len mapped2) 0) })
124121

125122
(test:case "map!" {
126123
(dict:map! mapped map_to_num)
127-
(test:eq (dict:size d2) (dict:size mapped))
124+
(test:eq (len d2) (len mapped))
128125
(test:eq (dict:get d2 "a") 1)
129126
(test:eq (dict:get d2 "b") 2)
130127
(test:eq (dict:get d2 "c") 3)
@@ -133,7 +130,7 @@
133130
(test:eq (dict:get mapped "c") 3)
134131

135132
(dict:map! empty map_to_num)
136-
(test:eq (dict:size empty) 0) })
133+
(test:eq (len empty) 0) })
137134

138135
(test:case "forEach" {
139136
(dict:forEach empty (fun (k v)
@@ -144,17 +141,17 @@
144141
(test:case "copy" {
145142
(let d2_copy (dict:copy d2))
146143
(dict:add d2_copy "d" 4)
147-
(test:eq (dict:size d2_copy) 4)
148-
(test:eq (dict:size d2) 3) })
144+
(test:eq (len d2_copy) 4)
145+
(test:eq (len d2) 3) })
149146

150147
(test:case "filter" {
151148
(let filtered (dict:filter d filter_str_keys))
152-
(test:eq (dict:size d) 6)
153-
(test:eq (dict:size filtered) 1)
149+
(test:eq (len d) 6)
150+
(test:eq (len filtered) 1)
154151
(test:eq (dict:get filtered "key") 2)
155152

156153
(let empty_filtered (dict:filter empty filter_str_keys))
157-
(test:eq (dict:size empty_filtered) 0) })
154+
(test:eq (len empty_filtered) 0) })
158155

159156
(test:case "asJson" {
160157
(test:eq (dict:asJson empty) "{}")
@@ -164,19 +161,19 @@
164161

165162
(test:case "filter!" {
166163
(dict:filter! d2 filter_odd)
167-
(test:eq (dict:size d2) 2)
164+
(test:eq (len d2) 2)
168165
(test:expect (dict:contains? d2 "a"))
169166
(test:expect (not (dict:contains? d2 "b")))
170167
(test:expect (dict:contains? d2 "c"))
171168
(test:eq (dict:get d2 "a") 1)
172169
(test:eq (dict:get d2 "c") 3)
173170

174171
(dict:filter! empty filter_odd)
175-
(test:eq (dict:size empty_filtered) 0) })
172+
(test:eq (len empty_filtered) 0) })
176173

177174
(test:case "update!" {
178175
(dict:update! d d2)
179-
(test:eq (dict:size d) 8)
176+
(test:eq (len d) 8)
180177
(test:eq (dict:get d "a") 1)
181178
(test:eq (dict:get d "c") 3)
182179
(test:eq (dict:get d "key") 2)
@@ -186,13 +183,13 @@
186183
(test:eq (dict:get d foo) "yes")
187184
(test:eq (dict:get d closure) foo)
188185

189-
(test:eq (dict:size d2) 2)
186+
(test:eq (len d2) 2)
190187
(dict:add d2 "a" 5)
191188
(test:eq (dict:get d "a") 1)
192189
(test:eq (dict:get d2 "a") 5)
193190

194191
(dict:update! d2 empty)
195-
(test:eq (dict:size d2) 2)
192+
(test:eq (len d2) 2)
196193
(test:eq (dict:get d2 "a") 5)
197194
(test:eq (dict:get d2 "c") 3)
198-
(test:eq (dict:size empty) 0) }) })
195+
(test:eq (len empty) 0) }) })

tests/functional-tests.ark

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
(let mean (recombine
3636
(fun (a b) (/ a b))
3737
list:sum
38-
list:size))
38+
len))
3939
(test:eq (mean [0 1 1 2 3 5 8 13]) 4.125)
4040
(test:eq (mean [0]) 0)
4141

tests/list-tests.ark

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
(test:expect (not (list:contains? [1 2 3] "1")))
3030
(test:expect (list:contains? ["1" "2" "3"] "1")) })
3131

32-
(test:case "size" {
33-
(test:eq (list:size []) 0)
34-
(test:eq (list:size [1 2 3]) 3) })
32+
(test:case "len" {
33+
(test:eq (len []) 0)
34+
(test:eq (len [1 2 3]) 3) })
3535

3636
(test:case "forEach" {
3737
(list:forEach a (fun (e) {

tests/math-tests.ark

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
(test:expect (math:even? 2))
4343
(test:expect (math:even? 0))
4444
(test:expect (math:even? -2))
45-
(test:expect (not (math:even 1)))
46-
(test:expect (not (math:even -1))) })
45+
(test:expect (not (math:even? 1)))
46+
(test:expect (not (math:even? -1))) })
4747

4848
(test:case "odd?" {
4949
(test:expect (math:odd? 1))

0 commit comments

Comments
 (0)