lua: math fns type-check args (math.sin() now errors instead of returning 0)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
This commit is contained in:
@@ -1215,19 +1215,27 @@
|
||||
(define lua-math-pi 3.141592653589793)
|
||||
(define lua-math-huge (/ 1.0 0.0))
|
||||
|
||||
(define lua-math-abs (fn (x) (abs x)))
|
||||
(define lua-math-ceil (fn (x) (ceil x)))
|
||||
(define lua-math-floor (fn (x) (floor x)))
|
||||
(define lua-math-sqrt (fn (x) (sqrt x)))
|
||||
(define lua-math-exp (fn (x) (exp x)))
|
||||
(define lua-math-sin (fn (x) (sin x)))
|
||||
(define lua-math-cos (fn (x) (cos x)))
|
||||
(define lua-math-tan (fn (x) (tan x)))
|
||||
(define lua-math-asin (fn (x) (asin x)))
|
||||
(define lua-math-acos (fn (x) (acos x)))
|
||||
(define lua-math-atan (fn (x) (atan x)))
|
||||
(define lua-math-atan2 (fn (y x) (atan2 y x)))
|
||||
(define lua-math-pow (fn (a b) (pow a b)))
|
||||
(define
|
||||
lua-math-num
|
||||
(fn (name x)
|
||||
(let ((n (lua-to-number x)))
|
||||
(cond
|
||||
((= n nil) (error (str "bad argument to '" name "' (number expected)")))
|
||||
(else n)))))
|
||||
|
||||
(define lua-math-abs (fn (x) (abs (lua-math-num "abs" x))))
|
||||
(define lua-math-ceil (fn (x) (ceil (lua-math-num "ceil" x))))
|
||||
(define lua-math-floor (fn (x) (floor (lua-math-num "floor" x))))
|
||||
(define lua-math-sqrt (fn (x) (sqrt (lua-math-num "sqrt" x))))
|
||||
(define lua-math-exp (fn (x) (exp (lua-math-num "exp" x))))
|
||||
(define lua-math-sin (fn (x) (sin (lua-math-num "sin" x))))
|
||||
(define lua-math-cos (fn (x) (cos (lua-math-num "cos" x))))
|
||||
(define lua-math-tan (fn (x) (tan (lua-math-num "tan" x))))
|
||||
(define lua-math-asin (fn (x) (asin (lua-math-num "asin" x))))
|
||||
(define lua-math-acos (fn (x) (acos (lua-math-num "acos" x))))
|
||||
(define lua-math-atan (fn (x) (atan (lua-math-num "atan" x))))
|
||||
(define lua-math-atan2 (fn (y x) (atan2 (lua-math-num "atan2" y) (lua-math-num "atan2" x))))
|
||||
(define lua-math-pow (fn (a b) (pow (lua-math-num "pow" a) (lua-math-num "pow" b))))
|
||||
|
||||
(define lua-math-log
|
||||
(fn (&rest args)
|
||||
|
||||
Reference in New Issue
Block a user