File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed
Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change 216216# @author https://github.com/SuperFola
217217(let decrement (fun (_x) (- _x 1)))
218218
219+ # @brief Multiply a number by -1, turning positive numbers negative and negative numbers positive
220+ # #param _x number
221+ # @author https://github.com/SuperFola
222+ (let negate (fun (_x) (* -1 _x)))
223+
219224# @brief Get a number to a given power
220225# @details Note that it's defined as exp(a * ln(x)), thus won't work for negative numbers
221226# @param _x the number to pow
Original file line number Diff line number Diff line change 3535 (test:eq (math:abs -1) 1)
3636 (test:eq (math:abs 0) 0)
3737 (test:eq (math:abs math:Inf) math:Inf)
38+ (test:eq (math:abs (math:negate math:Inf)) math:Inf)
3839 (test:eq (math:abs 1) 1) })
3940
4041 (test:case "even?" {
7172 (test:eq (math:decrement 1) 0)
7273 (test:eq (math:decrement 1.5) 0.5) })
7374
75+ (test:case "negate" {
76+ (test:eq (math:negate 0) 0)
77+ (test:eq (math:negate 1) -1)
78+ (test:eq (math:negate -1) 1)
79+ (test:eq (math:negate (math:negate 1)) 1) })
80+
7481 (test:case "pow" {
7582 (test:eq (math:pow 2 2) 4)
7683 (test:eq (math:pow 4 0.5) 2) })
You can’t perform that action at this time.
0 commit comments