diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2020-08-12 22:48:21 -0400 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2020-08-12 22:48:21 -0400 |
| commit | 58cd3c0c4b56cf9e65b7a532e7ecaa3b928a7091 (patch) | |
| tree | 844245c439895ca184dd493c55a9453aa2300ff3 /bqn.js | |
| parent | 09365aca8c9247452b41f2a0c72dd5e889792672 (diff) | |
Minor optimizations to call()
Diffstat (limited to 'bqn.js')
| -rw-r--r-- | bqn.js | 11 |
1 files changed, 4 insertions, 7 deletions
@@ -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); |
