aboutsummaryrefslogtreecommitdiff
path: root/bqn.js
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2020-08-12 22:48:21 -0400
committerMarshall Lochbaum <mwlochbaum@gmail.com>2020-08-12 22:48:21 -0400
commit58cd3c0c4b56cf9e65b7a532e7ecaa3b928a7091 (patch)
tree844245c439895ca184dd493c55a9453aa2300ff3 /bqn.js
parent09365aca8c9247452b41f2a0c72dd5e889792672 (diff)
Minor optimizations to call()
Diffstat (limited to 'bqn.js')
-rw-r--r--bqn.js11
1 files changed, 4 insertions, 7 deletions
diff --git a/bqn.js b/bqn.js
index 28436f5d..8f70176b 100644
--- a/bqn.js
+++ b/bqn.js
@@ -2,13 +2,10 @@
let assert = x => { if (!x) throw Error(); }
let has = x => x!==undefined;
let call = (f,x,w) => {
- let ff = f;
- if (typeof f === "function") {
- assert(!f.m1&&!f.m2);
- } else {
- ff = ()=>f;
- }
- return !has(x) ? x : ff(x,w);
+ if (x===undefined) return x;
+ if (typeof f !== "function") return f;
+ assert(!f.m1&&!f.m2);
+ return f(x, w);
}
let get1= i => (v=>(assert(v!==null),v))(i[0][i[1]]);
let get = i => i.a ? arr(i.map(get),i.sh) : get1(i);