extend basic math function to multi params
This commit is contained in:
parent
0dc0db98a9
commit
82827a300b
@ -94,18 +94,18 @@ function Library (ronin) {
|
||||
|
||||
// Math
|
||||
|
||||
this.add = function (a, b) {
|
||||
return a + b
|
||||
this.add = function (...args) {
|
||||
return args.reduce((sum, val) => sum + val)
|
||||
}
|
||||
|
||||
this.sub = function (a, b) {
|
||||
return a - b
|
||||
this.sub = function (...args) {
|
||||
return args.reduce((sum, val) => sum - val)
|
||||
}
|
||||
|
||||
this.mul = function (a, b) {
|
||||
return a * b
|
||||
this.mul = function (...args) {
|
||||
return args.reduce((sum, val) => sum * val)
|
||||
}
|
||||
this.div = function (a, b) {
|
||||
return a / b
|
||||
this.div = function (...args) {
|
||||
return args.reduce((sum, val) => sum / val)
|
||||
}
|
||||
}
|
||||
|
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