aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2020-12-22 21:05:38 -0500
committerMarshall Lochbaum <mwlochbaum@gmail.com>2020-12-22 21:05:38 -0500
commita472c6f1c6bf2f1f17a90ef510ede6162f739053 (patch)
tree384a3595ce8b68562a824d41b2e1472a8402d8f9
parent3a0c9aeebef6a133396a270a67592c6b958ab79d (diff)
Check that argument to Floor is a number in VM
-rw-r--r--docs/bqn.js6
1 files changed, 5 insertions, 1 deletions
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) // โ‰ข