Merge pull request #32 from lctrt/feat/math-extension
extend basic math function to multi params
This commit is contained in:
commit
7a30b60a8c
@ -144,20 +144,20 @@ function Library (ronin) {
|
|||||||
|
|
||||||
// Math
|
// Math
|
||||||
|
|
||||||
this.add = function (a, b) {
|
this.add = function (...args) {
|
||||||
return a + b
|
return args.reduce((sum, val) => sum + val)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.sub = function (a, b) {
|
this.sub = function (...args) {
|
||||||
return a - b
|
return args.reduce((sum, val) => sum - val)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.mul = function (a, b) {
|
this.mul = function (...args) {
|
||||||
return a * b
|
return args.reduce((sum, val) => sum * val)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.div = function (a, b) {
|
this.div = function (...args) {
|
||||||
return a / b
|
return args.reduce((sum, val) => sum / val)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.mod = function (a, b) {
|
this.mod = function (a, b) {
|
||||||
|
5
examples/math.lisp
Normal file
5
examples/math.lisp
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
(
|
||||||
|
(echo (add 2 3))
|
||||||
|
(echo (sub 22 3 4 5))
|
||||||
|
(echo (mul 2 3 4 5))
|
||||||
|
)
|
Loading…
x
Reference in New Issue
Block a user