From a472c6f1c6bf2f1f17a90ef510ede6162f739053 Mon Sep 17 00:00:00 2001 From: Marshall Lochbaum Date: Tue, 22 Dec 2020 21:05:38 -0500 Subject: Check that argument to Floor is a number in VM --- docs/bqn.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'docs') diff --git a/docs/bqn.js b/docs/bqn.js index 954439a3..29201421 100644 --- a/docs/bqn.js +++ b/docs/bqn.js @@ -132,6 +132,10 @@ let log = (x,w) => { } throw Error("โ‹†โผ: Arguments must be numbers"); } +let floor = (x,w) => { + if (isnum(x)) return Math.floor(x); + throw Error("โŒŠ๐•ฉ: Argument must be a number"); +} let lesseq = (x,w) => { let s=typeof w, t=typeof x; return +(s!==t ? s<=t : w<=x); @@ -186,7 +190,7 @@ let provide = [ ,times // ร— ,divide // รท ,power // โ‹† - ,(x,w) => Math.floor(x) // โŒŠ + ,floor // โŒŠ ,(x,w) => has(w)?+(x===w):x.sh?x.sh.length:0 // = ,lesseq // โ‰ค ,(x,w) => list(x.sh) // โ‰ข -- cgit v1.2.3