Skip to content

Commit 1ddb38e

Browse files
committed
adding Math.ark
1 parent b5e28e0 commit 1ddb38e

File tree

1 file changed

+21
-30
lines changed

1 file changed

+21
-30
lines changed

Math.ark

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,65 @@
11
###
22
# @meta Mathematics
3-
# @brief
4-
# ---
5-
# ---
6-
# @param
3+
# @brief Return the absolute value of a number
4+
# @param _x the number to get the absolute value of
75
# @author https://github.com/rstefanic
86
###
97
(let math:abs (fun (_x)
108
(if (< _x 0) (* -1 _x) _x)))
119

1210
###
1311
# @meta Mathematics
14-
# @brief
15-
# ---
16-
# ---
17-
# @param
12+
# @brief Return true if the number is even, false otherwise
13+
# @param _n the number
1814
# @author https://github.com/rstefanic
1915
###
2016
(let math:even (fun (_n)
2117
(= 0 (mod _n 2))))
2218

2319
###
2420
# @meta Mathematics
25-
# @brief
26-
# ---
27-
# ---
28-
# @param
21+
# @brief Return true if the number is odd, false otherwise
22+
# @param _n the number
2923
# @author https://github.com/rstefanic
3024
###
3125
(let math:odd (fun (_n)
3226
(= 1 (math:abs (mod _n 2)))))
3327

3428
###
3529
# @meta Mathematics
36-
# @brief
37-
# ---
38-
# ---
39-
# @param
30+
# @brief Get the minimum between two numbers
31+
# @param _a the first number
32+
# @param _b the second number
4033
# @author https://github.com/rstefanic
4134
###
4235
(let math:min (fun (_a _b)
4336
(if (< _a _b) _a _b)))
4437

4538
###
4639
# @meta Mathematics
47-
# @brief
48-
# ---
49-
# ---
50-
# @param
40+
# @brief Get the maximum between two numbers
41+
# @param _a the first number
42+
# @param _b the second number
5143
# @author https://github.com/rstefanic
5244
###
5345
(let math:max (fun (_a _b)
5446
(if (> _a _b) _a _b)))
5547

5648
###
5749
# @meta Mathematics
58-
# @brief
59-
# ---
60-
# ---
61-
# @param
50+
# @brief Get a number to a given power
51+
# @details Note that it's defined as exp(a * ln(x)), thus won't work for negative numbers
52+
# @param _x the number to pow
53+
# @param _a the exponent
6254
# @author https://github.com/SuperFola
6355
###
64-
(let math:pow (fun (x _a) (math:exp (* _a (math:ln x)))))
56+
(let math:pow (fun (_x _a) (math:exp (* _a (math:ln _x)))))
6557

6658
###
6759
# @meta Mathematics
68-
# @brief
69-
# ---
70-
# ---
71-
# @param
60+
# @brief Get the square root of a number
61+
# @details Square roots can't be taken for negative numbers for obvious reasons.
62+
# @param _x the number
7263
# @author https://github.com/SuperFola
7364
###
74-
(let math:sqrt (fun (x) (math:exp (* 0.5 (math:ln x)))))
65+
(let math:sqrt (fun (_x) (math:exp (* 0.5 (math:ln _x)))))

0 commit comments

Comments
 (0)