Skip to content

Commit 68ac247

Browse files
committed
chore!: add '?' suffix to math:even and math:odd, adding aliases before deprecating and removing
1 parent e131c0d commit 68ac247

File tree

6 files changed

+24
-12
lines changed

6 files changed

+24
-12
lines changed

List.ark

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@
223223
# @details The original list is not modified.
224224
# =begin
225225
# (import std.Math)
226-
# (print (list:filter [1 2 3 4 5 6 7 8 9] math:even)) # [2 4 6 8]
226+
# (print (list:filter [1 2 3 4 5 6 7 8 9] math:even?)) # [2 4 6 8]
227227
# =end
228228
# @author https://github.com/rstefanic
229229
(let filter (fun (_L _f) {

Math.ark

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,12 +169,24 @@
169169
# @brief Return true if the number is even, false otherwise
170170
# @param _n the number
171171
# @author https://github.com/rstefanic
172-
(let even (fun (_n) (= 0 (mod _n 2))))
172+
(let even? (fun (_n) (= 0 (mod _n 2))))
173+
174+
# @brief Return true if the number is even, false otherwise
175+
# @details **Deprecated, use `even?`**
176+
# @param _n the number
177+
# @author https://github.com/rstefanic
178+
(let even even?)
179+
180+
# @brief Return true if the number is odd, false otherwise
181+
# @param _n the number
182+
# @author https://github.com/rstefanic
183+
(let odd? (fun (_n) (= 1 (abs (mod _n 2)))))
173184

174185
# @brief Return true if the number is odd, false otherwise
186+
# @details **Deprecated, use `odd?`**
175187
# @param _n the number
176188
# @author https://github.com/rstefanic
177-
(let odd (fun (_n) (= 1 (abs (mod _n 2)))))
189+
(let odd odd?)
178190

179191
# @brief Get the minimum between two numbers
180192
# @param _a the first number

Range.ark

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
# =begin
6262
# (import std.Math)
6363
# (let obj (range:range 1 10))
64-
# (print (range:filter obj math:even)) # [2 4 6 8]
64+
# (print (range:filter obj math:even?)) # [2 4 6 8]
6565
# =end
6666
# @author https://github.com/SuperFola
6767
(let filter (fun (_range _fun) {

tests/list-tests.ark

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
(import std.List)
2-
(import std.Math :even)
2+
(import std.Math :even?)
33
(import std.Testing)
44

55
(let a [1 2 3])
@@ -69,7 +69,7 @@
6969
(test:eq (list:dropWhile a (fun (c) (< c 5))) []) })
7070

7171
(test:case "filter" {
72-
(test:eq (list:filter a math:even) [2])
72+
(test:eq (list:filter a math:even?) [2])
7373
(test:eq (list:filter a (fun (e) (> e 100))) [])
7474
(test:eq (list:filter [] (fun (e) (> e 100))) []) })
7575

tests/math-tests.ark

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@
3333

3434
(test:eq (math:abs -1) 1)
3535
(test:eq (math:abs 1) 1)
36-
(test:expect (math:even 2))
37-
(test:expect (math:even -2))
38-
(test:expect (math:odd 1))
39-
(test:expect (math:odd -1))
36+
(test:expect (math:even? 2))
37+
(test:expect (math:even? -2))
38+
(test:expect (math:odd? 1))
39+
(test:expect (math:odd? -1))
4040
(test:eq (math:min 1 2) 1)
4141
(test:eq (math:min 1 -2) -2)
4242
(test:eq (math:min 0.5 0.2) 0.2)

tests/range-tests.ark

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
(import std.Range:*)
2-
(import std.Math :even)
2+
(import std.Math :even?)
33
(import std.Testing)
44

55
(test:suite range {
@@ -17,7 +17,7 @@
1717
(range:forEach r (fun (e)
1818
(test:neq e nil)))
1919

20-
(let filtered (range:filter r math:even))
20+
(let filtered (range:filter r math:even?))
2121
(test:eq filtered [0 2 4 6 8])
2222

2323
(let mapped (range:map r (fun (e) (* e e))))

0 commit comments

Comments
 (0)