Skip to content

Instantly share code, notes, and snippets.

@razetime
Last active January 1, 2021 09:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save razetime/053c80f62b8b820b69721b18cdfc27eb to your computer and use it in GitHub Desktop.
Save razetime/053c80f62b8b820b69721b18cdfc27eb to your computer and use it in GitHub Desktop.
Userscript for executing apl code in chat
// ==UserScript==
// @name APL chat
// @version 2
// @grant GM_xmlhttpRequest
// @grant GM_listValues
// @match https://chat.stackexchange.com/*
// @run-at document-start
// @require https://gitlab.com/n9n/apl/-/raw/master/apl.js
// ==/UserScript==
// thanks to @cvzi for making it work correctly!
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
var observer = new MutationObserver(function(mutations, observer) {
// fired when a mutation occurs
console.log(mutations, observer);
let codes = document.getElementsByTagName("code");
for (let elem of codes) {
if(elem.innerText && !('interpreted' in elem.dataset) && elem.innerText[0] == '⋄') {
elem.dataset.interpreted = true; // see https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes#JavaScript_access
let result = ''
let color = 'red'
// Catch apl error and show it in orange color
try {
result = apl.fmt(apl(elem.innerText)).toString()
} catch(e) {
result = e.toString()
color = 'orange'
}
let tmp = document.createElement("div");
tmp.innerHTML = "<pre style=\"color:"+color+"\">"+result.replace("\n","<br>")+"</pre>";
let parent = elem.parentElement;
parent.appendChild(tmp.firstChild);
//console.log(result);
}
}
});
window.addEventListener('DOMContentLoaded', (event) => {
alert = function() {}; // Prevents ⎕← and ⍞← from trggering alerts
window.alert = function(){};
observer.observe(document, {
subtree: true,
ChildList:true,
attributes: true
});
});
@cvzi
Copy link

cvzi commented Dec 19, 2020

Saw your question on stackoverflow.com 😉

// ==UserScript==
// @name     APL chat
// @version  1
// @grant    GM_xmlhttpRequest
// @grant    GM_listValues
// @match    https://chat.stackexchange.com/*
// @run-at   document-start
// @require  https://cdn.jsdelivr.net/npm/apl@0.1.15/lib/apl.min.js
// ==/UserScript==

var MutationObserver = window.MutationObserver || window.WebKitMutationObserver;

var observer = new MutationObserver(function(mutations, observer) {
    // fired when a mutation occurs
    console.log(mutations, observer);
    let codes = document.getElementsByTagName("code");
        for (let elem of codes) {
            if(elem.innerText && !('interpreted' in elem.dataset) && elem.innerText[0] == '⋄') {
                elem.dataset.interpreted = true;  // see https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes#JavaScript_access
                let result = ''
                let color = 'red'
                // Catch apl error and show it in orange color
                try {
                    result = apl(elem.innerText).toString()
                } catch(e) {
                    result = e.toString()
                    color = 'orange'
                }
                let tmp = document.createElement("div");
                tmp.innerHTML = "<pre style=\"color:"+color+"\">"+result.replace("\n","<br>")+"</pre>";
                let parent = elem.parentElement;
                parent.appendChild(tmp.firstChild);
                //console.log(result);
            }
        }
});

window.addEventListener('DOMContentLoaded', (event) => {
      observer.observe(document, {
      subtree: true,
    ChildList:true,
      attributes: true
      //...
    });

});

@razetime
Copy link
Author

@cvzi wow, thank you so much! I was struggling with this for a while. Thanks for writing the comments so I could understand it as well.

@razetime
Copy link
Author

razetime commented Dec 30, 2020

Chrome version:

// ==UserScript==
// @name     APL chat
// @version  2
// @grant    GM_xmlhttpRequest
// @grant    GM_listValues
// @match    https://chat.stackexchange.com/*
// @run-at   document-start
// ==/UserScript==

// thanks to @cvzi for making it work correctly!


var MutationObserver = window.MutationObserver || window.WebKitMutationObserver;

window.onload = function() {
    var observer = new MutationObserver(function(mutations, observer) {
    // fired when a mutation occurs
    console.log(mutations, observer);
    let codes = document.getElementsByTagName("code");
        for (let elem of codes) {
            if(elem.innerText && !('interpreted' in elem.dataset) && elem.innerText[0] == '⋄') {
                elem.dataset.interpreted = true;  // see https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes#JavaScript_access
                let result = ''
                let color = 'red'
                // Catch apl error and show it in orange color
                try {
                    result = apl(elem.innerText).toString()
                } catch(e) {
                    result = e.toString()
                    color = 'orange'
                }
                let tmp = document.createElement("div");
                tmp.innerHTML = "<pre style=\"color:"+color+"\">"+result.replace("\n","<br>")+"</pre>";
                let parent = elem.parentElement;
                parent.appendChild(tmp.firstChild);
                //console.log(result);
            }
        }
});
    /**
 * Minified by jsDelivr using Terser v5.3.5.
 * Original file: /npm/apl@0.1.15/lib/apl.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
(function(){var e,t,r,n,o,a,s,c,i,f,h,p,u,l,g,y,d,w,v,m,b,D,A,E,M,x,k,R,S,_,N,I,O,L,P,j,C,q,U,z,F,B,J,X,T,$,H,K,V,G,W,Z,Y,Q,ee,te,re,ne,oe,ae,se,ce,ie,fe,he,pe,ue,le,ge,ye,de,we,ve,me,be,De,Ae,Ee,Me,xe,ke,Re,Se,_e,Ne,Ie,Oe,Le,Pe,je,Ce=[].slice,qe=[].indexOf||function(e){for(var t=0,r=this.length;t<r;t++)if(t in this&&this[t]===e)return t;return-1};ce=function(e){var t,r,n;for(t=1,r=0,n=e.length;r<n;r++)t*=e[r];return t},A=function(e){var t,r;for(t=0,r=e.length;t<r;t++)if(!e[t])return!1;return!0},he=function(e,t){var r,n;if(!("string"==typeof e||e instanceof Array))throw Error("\"assert typeof a is 'string' or a instanceof Array\" at src/helpers.coffee:20");if(!((n=t)===~~n&&0<=n))throw Error('"assert isInt n, 0" at src/helpers.coffee:21');if(!t)return e.slice(0,0);for(r=t*e.length;2*e.length<r;)e=e.concat(e);return e.concat(e.slice(0,r-e.length))},J=function(e,t){var r;for(r in t)e[r]=t[r];return e},null==this.Uint8Array&&(this.Uint8Array=Array),null==this.Uint16Array&&(this.Uint16Array=Array),null==this.Uint32Array&&(this.Uint32Array=Array),null==this.Int8Array&&(this.Int8Array=Array),null==this.Int16Array&&(this.Int16Array=Array),null==this.Int32Array&&(this.Int32Array=Array),null==(Se=Array.prototype).set&&(Se.set=function(e,t){var r,n,o;for(r=n=0,o=e.length;n<o;r=n+=1)this[t+r]=e[r]}),R=function(e,t){var r,n,o;if(!(e instanceof Array))throw Error('"assert a instanceof Array" at src/helpers.coffee:72');if(!(t instanceof Array))throw Error('"assert b instanceof Array" at src/helpers.coffee:73');if(e.length!==t.length)return!1;for(r=n=0,o=e.length;n<o;r=++n)if(e[r]!==t[r])return!1;return!0},M=function(e,t,r){var n,o,a,s;if(null==t&&(t=""),"string"!=typeof e)throw Error("\"assert typeof name is 'string'\" at src/errors.coffee:2");if("string"!=typeof t)throw Error("\"assert typeof message is 'string'\" at src/errors.coffee:3");if(null!=r){if("object"!=typeof r)throw Error("\"assert typeof opts is 'object'\" at src/errors.coffee:5");if(null!=r.aplCode&&null!=r.line&&null!=r.col){if("string"!=typeof r.aplCode)throw Error("\"assert typeof opts.aplCode is 'string'\" at src/errors.coffee:7");if("number"!=typeof r.line)throw Error("\"assert typeof opts.line is 'number'\" at src/errors.coffee:8");if("number"!=typeof r.col)throw Error("\"assert typeof opts.col is 'number'\" at src/errors.coffee:9");if("string"!=(s=typeof r.file)&&"undefined"!==s)throw Error("\"assert typeof opts.file in ['string', 'undefined']\" at src/errors.coffee:10");t+="\n"+(r.file||"-")+":#"+r.line+":"+r.col+"\n"+r.aplCode.split("\n")[r.line-1]+"\n"+he("_",r.col-1)+"^"}}for(o in(n=Error(t)).name=e,r)a=r[o],n[o]=a;throw n},me=function(){var e;return e=1<=arguments.length?Ce.call(arguments,0):[],M.apply(null,["SYNTAX ERROR"].concat(Ce.call(e)))},q=function(){var e;return e=1<=arguments.length?Ce.call(arguments,0):[],M.apply(null,["DOMAIN ERROR"].concat(Ce.call(e)))},G=function(){var e;return e=1<=arguments.length?Ce.call(arguments,0):[],M.apply(null,["LENGTH ERROR"].concat(Ce.call(e)))},ie=function(){var e;return e=1<=arguments.length?Ce.call(arguments,0):[],M.apply(null,["RANK ERROR"].concat(Ce.call(e)))},K=function(){var e;return e=1<=arguments.length?Ce.call(arguments,0):[],M.apply(null,["INDEX ERROR"].concat(Ce.call(e)))},Q=function(){var e;return e=1<=arguments.length?Ce.call(arguments,0):[],M.apply(null,["NONCE ERROR"].concat(Ce.call(e)))},Ae=function(){var e;return e=1<=arguments.length?Ce.call(arguments,0):[],M.apply(null,["VALUE ERROR"].concat(Ce.call(e)))},t=function(){function e(e,t,r,n){var o,a,s,c,i,f,h,p,u,l,g,y;if(this.data=e,this.shape=t,this.stride=r,this.offset=null!=n?n:0,null==this.shape&&(this.shape=[this.data.length]),null==this.stride&&(this.stride=ve(this.shape)),null==this.data.length)throw Error('"assert @data.length?" at src/array.coffee:95');if(!(this.shape instanceof Array))throw Error('"assert @shape instanceof Array" at src/array.coffee:96');if(!(this.stride instanceof Array))throw Error('"assert @stride instanceof Array" at src/array.coffee:97');if(!(0===this.data.length||(a=this.offset)===~~a&&0<=(u=a)&&u<this.data.length))throw Error('"assert @data.length is 0 or isInt @offset, 0, @data.length" at src/array.coffee:98');if(this.stride.length!==this.shape.length)throw Error('"assert @stride.length is ⍴⍴ @" at src/array.coffee:99');for(i=0,h=(l=this.shape).length;i<h;i++)if(!((s=l[i])===~~s&&0<=s))throw Error('"for x in @shape then assert isInt x, 0" at src/array.coffee:100');if(this.data.length)for(o=f=0,p=(g=this.stride).length;f<p;o=++f)if(!((c=g[o])===~~c&&-this.data.length<=(y=c)&&y<this.data.length+1))throw Error('"for x, i in @stride then assert isInt x, -@data.length, @data.length + 1" at src/array.coffee:102')}return e.prototype.empty=function(){var e,t,r;for(e=0,t=(r=this.shape).length;e<t;e++)if(!r[e])return!0;return!1},e.prototype.map=function(t){var r,n,o,a,s,c,i,f,h,p,u,l;if("function"!=typeof t)throw Error("\"assert typeof f is 'function'\" at src/array.coffee:109");if(r=[],!(a=this).empty()){for(c=a.data,i=a.shape,f=a.stride,h=i.length-1,o=a.offset,n=[],u=0,l=i.length;u<l;u+=1)n.push(0);for(;;){for(p=c[o],r.push(t(p,n)),s=h;s>=0&&n[s]+1===i[s];)o-=n[s]*f[s],n[s--]=0;if(s<0)break;n[s]++,o+=f[s]}}return new e(r,this.shape)},e.prototype.map2=function(t,r){var n,o,a,s,c,i,f,h,p,u,l,g,y,d,w,v,m,b,D,A;if(!(t instanceof e))throw Error('"assert a instanceof APLArray" at src/array.coffee:115');if("function"!=typeof r)throw Error("\"assert typeof f is 'function'\" at src/array.coffee:116");if(n=[],h=(a=this).data,u=a.shape,g=a.stride,p=(s=t).data,l=s.shape,y=s.stride,u.length!==l.length)throw Error('"assert shape.length is shape1.length" at src/array.coffee:48');for(m=0,D=u.length;0<=D?m<D:m>D;0<=D?++m:--m)if(u[f]!==l[f])throw Error('"for axis in [0...shape.length] then assert shape[axis] is shape1[axis]" at src/array.coffee:49');if(!a.empty()){for(d=u.length-1,c=a.offset,i=s.offset,o=[],b=0,A=d;b<=A;b+=1)o.push(0);for(;;){for(w=h[c],v=p[i],n.push(r(w,v,o)),f=d;f>=0&&o[f]+1===u[f];)c-=o[f]*g[f],i-=o[f]*y[f],o[f--]=0;if(f<0)break;o[f]++,c+=g[f],i+=y[f]}}return new e(n,this.shape)},e.prototype.toArray=function(){var e,t,r,n,o,a,s,c,i,f,h,p;if(e=[],!(t=this).empty()){for(n=t.data,o=t.shape,a=t.stride,s=o.length-1,i=t.offset,c=[],h=0,p=o.length;h<p;h+=1)c.push(0);for(;;){for(f=n[i],e.push(f),r=s;r>=0&&c[r]+1===o[r];)i-=c[r]*a[r],c[r--]=0;if(r<0)break;c[r]++,i+=a[r]}}return e},e.prototype.toInt=function(e,t){var r;return null==e&&(e=-1/0),null==t&&(t=1/0),"number"==typeof(r=this.unwrap())&&r===~~r&&e<=r&&r<t?r:q()},e.prototype.toBool=function(){return this.toInt(0,2)},e.prototype.toSimpleString=function(){var e,t,r;if(this.shape.length>1&&ie(),"string"==typeof this.data)return this.shape.length?0===this.shape[0]?"":1===this.stride[0]?this.data.slice(this.offset,this.offset+this.shape[0]):this.toArray.join(""):this.data[this.offset];for(t=0,r=(e=this.toArray()).length;t<r;t++)"string"!=typeof e[t]&&q();return e.join("")},e.prototype.isSingleton=function(){var e,t,r;for(e=0,t=(r=this.shape).length;e<t;e++)if(1!==r[e])return!1;return!0},e.prototype.isSimple=function(){return 0===this.shape.length&&!(this.data[this.offset]instanceof e)},e.prototype.unwrap=function(){return 1===ce(this.shape)?this.data[this.offset]:G()},e.prototype.getPrototype=function(){return this.empty()||"string"!=typeof this.data[this.offset]?0:" "},e.prototype.toString=function(){return T(this).join("\n")},e.prototype.repr=function(){return"new APLArray("+pe(this.data)+","+pe(this.shape)+","+pe(this.stride)+","+pe(this.offset)+")"},e}(),ve=function(e){var t,r,n,o;if(!(e instanceof Array))throw Error('"assert shape instanceof Array" at src/array.coffee:155');if(0===e.length)return[];for((r=Array(e.length))[r.length-1]=1,t=o=r.length-2;o>=0;t=o+=-1){if(!((n=e[t])===~~n&&0<=n))throw Error('"assert isInt shape[i], 0" at src/array.coffee:160');r[t]=r[t+1]*e[t+1]}return r},t.zero=new t([0],[]),t.one=new t([1],[]),t.zilde=new t([],[0]),t.scalar=function(e){return new t([e],[])},t.bool=[t.zero,t.one],N=function(e){return"number"==typeof e?new o(e,0):e instanceof o?e:q()},ye=function(e,t){return 0!==t?new o(e,t):e},o=function(){var e,t,r,n,o,a,s,c,i,f,h,p,u,l,g,y,d,w,v,m,b,D,A;function E(e,t){if(this.re=e,this.im=null!=t?t:0,"number"!=typeof this.re)throw Error("\"assert typeof @re is 'number'\" at src/complex.coffee:20");if("number"!=typeof this.im)throw Error("\"assert typeof @im is 'number'\" at src/complex.coffee:21");(isNaN(this.re)||isNaN(this.im))&&q("NaN")}return E.prototype.toString=function(){return(""+this.re).replace("Infinity","∞").replace(/-/g,"¯")+"J"+(""+this.im).replace("Infinity","∞").replace(/-/g,"¯")},E.prototype.repr=function(){return"new Complex("+pe(this.re)+","+pe(this.im)+")"},E.exp=c=function(e){var t;return e=N(e),t=Math.exp(e.re),ye(t*Math.cos(e.im),t*Math.sin(e.im))},E.log=l=function(e){return"number"==typeof e&&e>0?Math.log(e):(e=N(e),ye(Math.log(Math.sqrt(e.re*e.re+e.im*e.im)),a(e)))},E.conjugate=function(e){return new E(e.re,-e.im)},E.negate=y=function(e){return new E(-e.re,-e.im)},E.itimes=u=function(e){return e=N(e),ye(-e.im,e.re)},E.negitimes=d=function(e){return e=N(e),ye(e.im,-e.re)},E.add=t=function(e,t){return e=N(e),t=N(t),ye(e.re+t.re,e.im+t.im)},E.subtract=D=function(e,t){return e=N(e),t=N(t),ye(e.re-t.re,e.im-t.im)},E.multiply=g=function(e,t){return e=N(e),t=N(t),ye(e.re*t.re-e.im*t.im,e.re*t.im+e.im*t.re)},E.divide=s=function(e,t){var r;return e=N(e),r=(t=N(t)).re*t.re+t.im*t.im,ye((e.re*t.re+e.im*t.im)/r,(t.re*e.im-t.im*e.re)/r)},E.pow=w=function(e,t){var r;return typeof e==(r=typeof t)&&"number"===r&&e>=0?Math.pow(e,t):c(g(t,l(e)))},E.sqrt=b=function(e){return"number"==typeof e&&e>=0?Math.sqrt(e):w(e,.5)},E.magnitude=function(e){return Math.sqrt(e.re*e.re+e.im*e.im)},E.direction=a=function(e){return Math.atan2(e.im,e.re)},E.sin=function(e){return d(m(u(e)))},E.cos=function(e){return o(u(e))},E.tan=function(e){return d(A(u(e)))},E.asin=r=function(e){return e=N(e),d(l(t(u(e),b(D(1,w(e,2))))))},E.acos=e=function(e){var r;return e=N(e),(r=d(l(t(e,b(D(w(e,2),1))))))instanceof E&&(r.re<0||0===r.re&&r.im<0)?y(r):r},E.atan=n=function(e){var r;return e=N(e),r=u(e),g(new E(0,.5),D(l(D(1,r)),l(t(1,r))))},E.sinh=m=function(e){var t;return t=c(e),g(.5,D(t,s(1,t)))},E.cosh=o=function(e){var r;return r=c(e),g(.5,t(r,s(1,r)))},E.tanh=A=function(e){var r,n;return r=c(e),n=s(1,r),s(D(r,n),t(r,n))},E.asinh=function(e){return u(r(d(e)))},E.acosh=function(t){var r;return r=(t=N(t)).im>0||0===t.im&&t.re<=1?1:-1,g(new E(0,r),e(t))},E.atanh=function(e){return u(n(d(e)))},E.floor=f=function(e){var t,r,n,o,a,s;return"number"==typeof e?Math.floor(e):(e=N(e),o=(a=[Math.floor(e.re),Math.floor(e.im)])[0],r=a[1],(n=(s=[e.re-o,e.im-r])[0])+(t=s[1])>=1&&(n>=t?o++:r++),ye(o,r))},E.ceil=function(e){var t,r,n,o,a,s;return"number"==typeof e?Math.ceil(e):(e=N(e),r=(a=[Math.ceil(e.re),Math.ceil(e.im)])[1],(n=(s=[(o=a[0])-e.re,r-e.im])[0])+(t=s[1])>=1&&(n>=t?o--:r--),ye(o,r))},p=function(e){return 0===e||e instanceof E&&0===e.re&&0===e.im},E.residue=v=function(e,t){var r;return typeof e==(r=typeof t)&&"number"===r?0===e?t:t-e*Math.floor(t/e):p(e)?t:D(t,g(e,f(s(t,e))))},E.isint=function(e){return"number"==typeof e?e===Math.floor(e):e.re===Math.floor(e.re)&&e.im===Math.floor(e.im)},i=function(e){return"number"==typeof e?Math.abs(e):(e.re<0&&(e=y(e)),e.im<0&&(e=u(e)),0===e.re&&(e=e.im),e)},E.gcd=h=function(e,t){var r,n,o;if(typeof e==(r=typeof t)&&"number"===r){for(;t;)e=(n=[t,e%t])[0],t=n[1];return Math.abs(e)}for(;!p(t);)e=(o=[t,v(t,e)])[0],t=o[1];return i(e)},E.lcm=function(e,t){var r;return r=g(e,t),p(r)?r:s(r,h(e,t))},E}(),h=(_e=[1,2,3,4,5,6,7,8,9,10,11,12])[0],w=_e[1],c=_e[2],y=_e[3],p=_e[4],a=_e[5],f=_e[6],g=_e[7],l=_e[8],d=_e[9],i=_e[10],s=_e[11],Re=function(){function e(e,t,r){this.code=e,this.addr=t,this.env=r}return e.prototype.toFunction=function(){return e=this,function(t,r){return Ee({code:e.code,env:e.env.concat([[t,e,r]]),pc:e.addr})};var e},e.prototype.toString=function(){return"λ"},e}(),Ee=function(e){var r,n,o,u,v,m,b,D,A,E,x,k,R,S,_,N,I,O,L,P;if(n=e.code,o=e.env,A=e.stack,b=e.pc,!(n instanceof Array))throw Error('"assert code instanceof Array" at src/vm.coffee:9');if(!(o instanceof Array))throw Error('"assert env instanceof Array" at src/vm.coffee:10');for(k=0,S=o.length;k<S;k++)if(!((v=o[k])instanceof Array))throw Error('"for frame in env then assert frame instanceof Array" at src/vm.coffee:11');for(null==A&&(A=[]),null==b&&(b=0);;)switch(n[b++]){case h:A.push(n[b++]);break;case w:for(r=[],R=0,_=(N=A.splice(A.length-n[b++])).length;R<_;R++)x=N[R],r.push(x.isSimple()?x.unwrap():x);A.push(new t(r));break;case c:A.push(null!=(I=o[n[b++]][n[b++]])?I:Ae());break;case y:o[n[b++]][n[b++]]=A[A.length-1];break;case p:if(E=(O=A.splice(-2))[0],"function"==typeof(u=O[1])){if(E instanceof Re&&(E=E.toFunction()),u.cps)return void u(E,void 0,void 0,(function(e){A.push(e),Ee({code:n,env:o,stack:A,pc:b})}));A.push(u(E))}else A.push(n,b,o),n=u.code,b=u.addr,o=u.env.concat([[E,u,null]]);break;case a:if(E=(L=A.splice(-3))[0],u=L[1],r=L[2],"function"==typeof u){if(E instanceof Re&&(E=E.toFunction()),r instanceof Re&&(r=r.toFunction()),u.cps)return void u(E,r,void 0,(function(e){A.push(e),Ee({code:n,env:o,stack:A,pc:b})}));A.push(u(E,r))}else A.push(n,b,o),n=u.code,b=u.addr,o=u.env.concat([[E,u,r]]);break;case f:D=n[b++],A.push(new Re(n,b,o)),b+=D;break;case g:if(1===A.length)return A[0];P=A.splice(-4,3),n=P[0],b=P[1],o=P[2];break;case l:A.pop();break;case d:m=n[b++],r=A[A.length-1].toArray().reverse(),1===(r=function(){var e,n,o;for(o=[],e=0,n=r.length;e<n;e++)x=r[e],o.push(x instanceof t?x:new t([x],[]));return o}()).length?r=he(r,m):r.length!==m&&G(),A.push.apply(A,r);break;case i:m=n[b++],A[A.length-1].toBool()||(b+=m);break;case s:v=o[o.length-1],A.push(n[b++](v[0],v[2]));break;default:M("Unrecognized instruction: "+n[b-1]+", pc:"+b)}},De=function(){var e,r,n,o;return o={code:[1,new t([new t(["W",new t("^([ \\t]+|[⍝\\#].*)+",[18],[1],0)],[2],[1],0),new t(["L",new t("^[\\n\\r]+",[8],[1],0)],[2],[1],0),new t(["⋄",new t("^[◇⋄]",[5],[1],0)],[2],[1],0),new t(["N",new t("^(¯?(0x[0-9A-Fa-f]+|[0-9]*\\.?[0-9]+([Ee][+¯]?[0-9]+)?|¯|∞)([Jj]¯?(0x[0-9A-Fa-f]+|[0-9]*\\.?[0-9]+([Ee][+¯]?[0-9]+)?|¯|∞))?)",[122],[1],0)],[2],[1],0),new t(["S",new t("^(('[^']*')+|(\"[^\"]*\"))+",[24],[1],0)],[2],[1],0),new t([".",new t("^[\\(\\)\\[\\]\\{\\}:;←]",[18],[1],0)],[2],[1],0),new t(["J",new t("^«[^»]*»",[8],[1],0)],[2],[1],0),new t(["X",new t("^(⎕?[A-Za-z_][0-9A-Za-z_]*|⍺⍺|⍵⍵|∇∇|[^¯'\":«»])",[46],[1],0)],[2],[1],0)],[8],[1],0),3,0,75,5,4,0,82,9,7,209,3,1,0,3,0,62,5,3,0,14,1,new t([0],[],[],0),6,11,8,9,1,new t(["$",new t("",[0],[1],0)],[2],[1],0),3,0,43,5,8,9,3,1,0,3,0,43,5,3,0,58,3,0,27,5,1,new t([1],[],[],0),2,1,1,new t([1],[1],[1],0),2,2,3,0,68,3,0,82,6,6,4,1,3,9,1,new t([1],[],[],0),3,0,42,3,1,3,3,0,79,3,0,27,5,5,3,0,3,5,6,4,1,4,9,3,1,4,1,new t([0],[],[],0),2,2,1,new t([0,1],[2],[1],0),2,2,3,0,68,3,0,82,6,4,1,5,9,1,new t([1],[],[],0),2,1,1,new t([0],[1],[1],0),2,2,3,0,68,3,1,4,2,1,1,new t([0],[1],[1],0),2,2,3,0,68,3,1,3,6,3,0,70,5,6,3,0,70,5,4,1,6,9,3,1,5,3,1,6,3,0,70,5,2,2,3,0,67,1,new t(".",[],[],0),3,0,14,3,1,5,6,6,4,1,5,9,3,1,0,3,0,26,3,1,6,3,0,79,5,6,3,1,1,5,3,0,13,3,1,5,3,1,6,2,2,3,0,43,5,6,8,4,0,83,9,7,255,3,1,0,3,0,83,5,3,0,75,5,4,1,3,9,1,new t([1],[],[],0),2,1,1,new t([1],[1],[1],0),2,2,3,0,68,3,1,3,6,3,0,79,3,0,27,5,5,3,0,0,3,0,10,5,5,4,1,4,9,3,1,4,3,0,13,3,1,4,3,0,13,1,new t([0],[],[],0),6,3,0,26,1,new t([-1],[],[],0),6,3,0,13,3,1,3,6,6,4,1,3,9,3,1,3,3,0,66,1,new t("W",[],[],0),3,0,15,1,new t([0],[],[],0),2,1,1,new t([1],[1],[1],0),2,2,3,0,68,3,1,3,6,6,6,4,1,3,9,1,new t("{",[],[],0),4,1,5,9,3,1,3,3,0,66,1,new t([0],[],[],0),2,1,1,new t([1],[1],[1],0),2,2,3,0,68,3,1,3,6,7,101,1,new t("([{",[3],[1],0),3,0,29,3,2,0,6,11,21,9,3,2,0,3,0,13,3,1,5,6,4,1,5,3,0,78,1,new t([1],[],[],0),6,8,9,1,new t(")]}",[3],[1],0),3,0,29,3,2,0,6,11,20,9,3,1,5,3,0,26,1,new t([-1],[],[],0),6,4,1,5,3,0,78,1,new t([1],[],[],0),6,8,9,1,new t("L",[],[],0),3,0,14,3,2,0,6,11,21,9,3,1,5,3,0,70,1,new t([-1],[],[],0),6,3,0,70,5,3,0,14,1,new t("{",[],[],0),6,8,9,1,new t([1],[],[],0),8,3,0,27,5,5,6,4,1,3,8,4,0,84,8],nSlots:85,vars:{tds:{scopeDepth:0,slot:82,category:1},tpairs:{scopeDepth:0,slot:83,category:2},tokenize:{scopeDepth:0,slot:84,category:2},"+":{category:2,slot:0,scopeDepth:0},"-":{category:2,slot:1,scopeDepth:0},"−":{category:2,slot:2,scopeDepth:0},"×":{category:2,slot:3,scopeDepth:0},"÷":{category:2,slot:4,scopeDepth:0},"*":{category:2,slot:5,scopeDepth:0},"⋆":{category:2,slot:6,scopeDepth:0},"⍟":{category:2,slot:7,scopeDepth:0},"|":{category:2,slot:8,scopeDepth:0},"∣":{category:2,slot:9,scopeDepth:0},"\\":{category:3,slot:10,scopeDepth:0},"⍀":{category:3,slot:11,scopeDepth:0},"○":{category:2,slot:12,scopeDepth:0},",":{category:2,slot:13,scopeDepth:0},"=":{category:2,slot:14,scopeDepth:0},"≠":{category:2,slot:15,scopeDepth:0},"<":{category:2,slot:16,scopeDepth:0},">":{category:2,slot:17,scopeDepth:0},"≤":{category:2,slot:18,scopeDepth:0},"≥":{category:2,slot:19,scopeDepth:0},"≡":{category:2,slot:20,scopeDepth:0},"∘":{category:4,slot:21,scopeDepth:0},"∪":{category:2,slot:22,scopeDepth:0},"∩":{category:2,slot:23,scopeDepth:0},"⊥":{category:2,slot:24,scopeDepth:0},".":{category:4,slot:25,scopeDepth:0},"↓":{category:2,slot:26,scopeDepth:0},"¨":{category:3,slot:27,scopeDepth:0},"⊤":{category:2,slot:28,scopeDepth:0},"∊":{category:2,slot:29,scopeDepth:0},"∈":{category:2,slot:30,scopeDepth:0},"!":{category:2,slot:31,scopeDepth:0},"⍎":{category:2,slot:32,scopeDepth:0},"⍷":{category:2,slot:33,scopeDepth:0},"⌊":{category:2,slot:34,scopeDepth:0},"⌈":{category:2,slot:35,scopeDepth:0},_fork1:{category:2,slot:36,scopeDepth:0},_fork2:{category:2,slot:37,scopeDepth:0},"⍕":{category:2,slot:38,scopeDepth:0},"⍋":{category:2,slot:39,scopeDepth:0},"⍒":{category:2,slot:40,scopeDepth:0},"⍁":{category:4,slot:41,scopeDepth:0},"⍳":{category:2,slot:42,scopeDepth:0},"⊂":{category:2,slot:43,scopeDepth:0},"~":{category:2,slot:44,scopeDepth:0},"∨":{category:2,slot:45,scopeDepth:0},"∧":{category:2,slot:46,scopeDepth:0},"^":{category:2,slot:47,scopeDepth:0},"⍱":{category:2,slot:48,scopeDepth:0},"⍲":{category:2,slot:49,scopeDepth:0},"⍣":{category:4,slot:50,scopeDepth:0},"get_⎕":{category:2,slot:51,scopeDepth:0},"⎕":{category:1},"set_⎕":{category:2,slot:52,scopeDepth:0},"get_⍞":{category:2,slot:53,scopeDepth:0},"⍞":{category:1},"set_⍞":{category:2,slot:54,scopeDepth:0},"get_⎕IO":{category:2,slot:55,scopeDepth:0},"⎕IO":{category:1},"set_⎕IO":{category:2,slot:56,scopeDepth:0},"⎕DL":{category:2,slot:57,scopeDepth:0},"⎕RE":{category:2,slot:58,scopeDepth:0},"⎕UCS":{category:2,slot:59,scopeDepth:0},"?":{category:2,slot:60,scopeDepth:0},"↗":{category:2,slot:61,scopeDepth:0},"⍴":{category:2,slot:62,scopeDepth:0},"⌽":{category:2,slot:63,scopeDepth:0},"⊖":{category:2,slot:64,scopeDepth:0},"/":{category:3,slot:65,scopeDepth:0},"⌿":{category:3,slot:66,scopeDepth:0},"⌷":{category:2,slot:67,scopeDepth:0},_index:{category:2,slot:68,scopeDepth:0},_substitute:{category:2,slot:69,scopeDepth:0},"↑":{category:2,slot:70,scopeDepth:0},"⍉":{category:2,slot:71,scopeDepth:0},"⍠":{category:4,slot:72,scopeDepth:0},"⍬":{scopeDepth:0,slot:73,category:1},_hook:{scopeDepth:0,slot:74,category:4},"⊃":{scopeDepth:0,slot:75,category:2},"⍪":{scopeDepth:0,slot:76,category:2},"⊢":{scopeDepth:0,slot:77,category:2},"⊣":{scopeDepth:0,slot:78,category:2},"≢":{scopeDepth:0,slot:79,category:2},"⌹":{scopeDepth:0,slot:80,category:2},"⍨":{scopeDepth:0,slot:81,category:3}}},e=o.code,n=o.vars,o.nSlots,r=null,function(o){var a,s,c,i,f,h,p,u,l,g;if(null==r){for(f in c=[[]],n)h=n[f],c[0][h.slot]=Me[f];Ee({code:e,env:c}),r=c[0][n.tokenize.slot].toFunction()}for(g=[],i=p=0,u=(s=(a=r(new t(o))).toArray()).length,l=a.shape[1];l>0?p<u:p>u;i=p+=l)g.push({type:s[i],value:s[i+1].toArray().join("")});return g}}(),ne=function(e,t){var r,n,o,a,s,c,i;return null==t&&(t={}),i=De(e),r=0,c=i[r++],a=function(r){return me(r,{file:t.file,line:c.startLine,col:c.startCol,aplCode:e})},n=function(){var e,t,n,a,s;for(e=["B"];;){if(n=c.type,qe.call("$};",n)>=0)return e;for(;"⋄"===(a=c.type)||"L"===a?c=i[r++]:void 0;);if(s=c.type,qe.call("$};",s)>=0)return e;t=o(),(":"===c.type?c=i[r++]:void 0)&&(t=[":",t,o()]),e.push(t)}},o=function(){var e,t,s,f,h;for(e=["."];;){if(s=c,"N"===(f=c.type)||"S"===f||"X"===f||"J"===f?c=i[r++]:void 0)t=[s.type,s.value];else if("("===c.type?c=i[r++]:void 0)(")"===c.type?c=i[r++]:void 0)?t=["⍬"]:(t=o(),")"===c.type?c=i[r++]:a("Expected token of type ')' but got '"+c.type+"'"));else if("{"===c.type?c=i[r++]:void 0){for(t=["{",n()];";"===c.type?c=i[r++]:void 0;)t.push(n());"}"===c.type?c=i[r++]:a("Expected token of type '}' but got '"+c.type+"'")}else a("Encountered unexpected token of type '"+c.type+"'");if("["===c.type?c=i[r++]:void 0){for(t=["[",t];;)if(";"===c.type?c=i[r++]:void 0)t.push(null);else{if("]"===c.type){t.push(null);break}if(t.push(o()),"]"===c.type)break;";"===c.type?c=i[r++]:a("Expected token of type ';' but got '"+c.type+"'")}"]"===c.type?c=i[r++]:a("Expected token of type ']' but got '"+c.type+"'")}if("←"===c.type?c=i[r++]:void 0)return e.concat([["←",t,o()]]);if(e.push(t),h=c.type,qe.call(")]}:;⋄L$",h)>=0)return e}},s=n(),"$"===c.type?c=i[r++]:a("Expected token of type '$' but got '"+c.type+"'"),s},Me={},Z=function(e,r){var n,a,s,c,i,f,h,p,u,l,g,y,d,w,v,m,b,D,A,E,M,x,k;if(e instanceof t){if(r instanceof t){if(e.shape.length!==r.shape.length)return!1;for(n=D=0,M=e.shape.length;D<M;n=D+=1)if(e.shape[n]!==r.shape[n])return!1;if(a=!0,p=(s=e).data,l=s.shape,y=s.stride,u=(c=r).data,g=c.shape,d=c.stride,l.length!==g.length)throw Error('"assert shape.length is shape1.length" at src/array.coffee:48');for(n=A=0,x=l.length;0<=x?A<x:A>x;n=0<=x?++A:--A)if(l[h]!==g[h])throw Error('"for axis in [0...shape.length] then assert shape[axis] is shape1[axis]" at src/array.coffee:49');if(!s.empty()){for(w=l.length-1,i=s.offset,f=c.offset,v=[],n=E=0,k=w;E<=k;n=E+=1)v.push(0);for(;;){for(m=p[i],b=u[f],Z(m,b)||(a=!1),h=w;h>=0&&v[h]+1===l[h];)i-=v[h]*y[h],f-=v[h]*d[h],v[h--]=0;if(h<0)break;v[h]++,i+=y[h],f+=d[h]}}return a}return!1}return!(r instanceof t)&&(e instanceof o&&r instanceof o?e.re===r.re&&e.im===r.im:e===r)},ee=function(e,t){return e===t||Math.abs(e-t)<1e-11},k=function(e,r){var n,a,s,c,i,f,h,p,u,l,g,y,d,w,v,m,b,D,A,E,M,x,R;if(e instanceof t){if(r instanceof t){if(e.shape.length!==r.shape.length)return!1;for(n=D=0,M=e.shape.length;D<M;n=D+=1)if(e.shape[n]!==r.shape[n])return!1;if(a=!0,p=(s=e).data,l=s.shape,y=s.stride,u=(c=r).data,g=c.shape,d=c.stride,l.length!==g.length)throw Error('"assert shape.length is shape1.length" at src/array.coffee:48');for(n=A=0,x=l.length;0<=x?A<x:A>x;n=0<=x?++A:--A)if(l[h]!==g[h])throw Error('"for axis in [0...shape.length] then assert shape[axis] is shape1[axis]" at src/array.coffee:49');if(!s.empty()){for(w=l.length-1,i=s.offset,f=c.offset,v=[],n=E=0,R=w;E<=R;n=E+=1)v.push(0);for(;;){for(m=p[i],b=u[f],k(m,b)||(a=!1),h=w;h>=0&&v[h]+1===l[h];)i-=v[h]*y[h],f-=v[h]*d[h],v[h--]=0;if(h<0)break;v[h]++,i+=y[h],f+=d[h]}}return a}return!1}return!(r instanceof t)&&(null!=e&&null!=r&&("number"==typeof e&&(e=new o(e)),"number"==typeof r&&(r=new o(r)),e instanceof o?r instanceof o&&ee(e.re,r.re)&&ee(e.im,r.im):e===r))},S=function(e){return 0!==e&&1!==e?q():e},$=function(e,r){var n,o,a,s,c,i,f,h,p,u;if(!((a=r)===~~a&&0<=a))throw Error('"assert isInt rank, 0" at src/vocabulary/vhelpers.coffee:118');if(null==e)return[];if(!(e instanceof t))throw Error('"assert axes instanceof APLArray" at src/vocabulary/vhelpers.coffee:120');if(1===e.shape.length&&1===e.shape[0]||me(),(n=e.unwrap())instanceof t){for(o=f=0,h=(n=n.toArray()).length;f<h;o=++f)(s=i=n[o])===~~s&&0<=(p=s)&&p<r||q(),qe.call(n.slice(0,o),i)>=0&&q("Non-unique axes");return n}return(c=n)===~~c&&0<=(u=c)&&u<r?[n]:q()},b=function(e){return e.isAdverb=!0,e},O=function(e){return e.isConjunction=!0,e},P=function(e){return e.cps=!0,e},D=function(e,t){if("string"==typeof e)e=[e];else if(!(e instanceof Array))throw Error('"assert aliases instanceof Array" at src/vocabulary/vhelpers.coffee:146');return t.aliases=e,t},(m=function(e){var t,r,n,o,a,s,c;for(r in e)for(n=e[r],Me[r]=n,o=0,a=(c=null!=(s=null!=n?n.aliases:void 0)?s:[]).length;o<a;o++)t=c[o],Me[t]=n})({"+":(xe=function(e,r){return r.identity=e instanceof t?e:t.scalar(e),r})(0,(oe=function(e){var r,n,o,a;return n=e.monad,r=e.dyad,a=n?function(e){var r;return e instanceof t?e.map(a):("number"==typeof(r=n(e))&&isNaN(r)&&q("NaN"),r)}:Q,o=r?function(e,n){var a,s,c,i,f,h;switch(16*(e instanceof t?e.isSingleton()?1:2:0)+(n instanceof t?n.isSingleton()?1:2:0)){case 0:return"number"==typeof(s=r(e,n))&&isNaN(s)&&q("NaN"),s;case 1:case 2:return n.map((function(t){return o(e,t)}));case 16:case 32:return e.map((function(e){return o(e,n)}));case 18:return c=e.data[e.offset],n.map((function(e){return o(c,e)}));case 33:case 17:return i=n.data[n.offset],e.map((function(e){return o(e,i)}));case 34:for(e.shape.length!==n.shape.length&&ie(),a=f=0,h=e.shape.length;f<h;a=f+=1)e.shape[a]!==n.shape[a]&&G();return e.map2(n,o);default:throw Error('"else assert 0" at src/vocabulary/vhelpers.coffee:40')}}:Q,function(e,r){if(!(e instanceof t))throw Error('"assert ⍵ instanceof APLArray" at src/vocabulary/vhelpers.coffee:44');if(!(r instanceof t||null==r))throw Error('"assert ⍺ instanceof APLArray or not ⍺?" at src/vocabulary/vhelpers.coffee:45');return(null!=r?o:a)(e,r)}})({monad:(te=function(e,t){return function(r,n,o){return"number"!=typeof r||null!=n&&"number"!=typeof n?(r=N(r),null!=n&&(n=N(n)),t(r,n,o)):e(r,n,o)}})((function(e){return e}),o.conjugate),dyad:te((function(e,t){return t+e}),(function(e,t){return o.add(t,e)}))})),"-":D("−",xe(0,oe({monad:te((function(e){return-e}),o.negate),dyad:te((function(e,t){return t-e}),(function(e,t){return o.subtract(t,e)}))}))),"×":xe(1,oe({monad:te((function(e){return(e>0)-(e<0)}),(function(e){var t;return t=Math.sqrt(e.re*e.re+e.im*e.im),ye(e.re/t,e.im/t)})),dyad:te((function(e,t){return t*e}),(function(e,t){return o.multiply(t,e)}))})),"÷":xe(1,oe({monad:te((function(e){return 1/e}),(function(e){var t;return t=e.re*e.re+e.im*e.im,ye(e.re/t,-e.im/t)})),dyad:te((function(e,t){return t/e}),(function(e,t){return o.divide(t,e)}))})),"*":D("⋆",xe(1,oe({monad:te(Math.exp,o.exp),dyad:function(e,t){return o.pow(t,e)}}))),"⍟":oe({monad:o.log,dyad:function(e,t){var r;return typeof t==(r=typeof e)&&"number"===r&&t>0&&e>0?Math.log(e)/Math.log(t):o.divide(o.log(e),o.log(t))}}),"|":D("∣",xe(0,oe({monad:te((function(e){return Math.abs(e)}),o.magnitude),dyad:function(e,t){return o.residue(t,e)}})))}),m({"\\":b((function(e,t,r){return"function"==typeof e?ge(e,void 0,r):B(e,t,r)})),"⍀":b((function(e,r,n){return null==n&&(n=t.zero),"function"==typeof e?ge(e,void 0,n):B(e,r,n)}))}),ge=function(e,r,n){if(void 0!==r)throw Error("\"assert typeof g is 'undefined'\" at src/vocabulary/backslash.coffee:44");return function(r,o){if(null!=o)throw Error('"assert not ⍺?" at src/vocabulary/backslash.coffee:46');return r.shape.length?(n=n?n.toInt(0,r.shape.length):r.shape.length-1,r.map((function(o,a){var s,c,i,f,h,p,u;for(c=r.offset,s=f=0,p=a.length;f<p;s=++f)c+=a[s]*r.stride[s];for(o instanceof t||(o=t.scalar(o)),h=0,u=a[n];h<u;h+=1)c-=r.stride[n],(i=r.data[c])instanceof t||(i=t.scalar(i)),o=e(o,i);return o.shape.length||(o=o.unwrap()),o}))):r}},B=function(e,r,n){var o,a,s,c,i,f,h,p,u,l,g,y,d;for(e.shape.length||Q("Expand of scalar not implemented"),n=n?n.toInt(0,e.shape.length):e.shape.length-1,r.shape.length>1&&ie(),o=r.toArray(),(p=e.shape.slice(0))[n]=o.length,a=[],i=0,g=0,y=o.length;g<y;g++)(u=l=o[g])===~~u&&0<=(d=u)&&d<2||q(),a.push(l>0?i++:null);if(i!==e.shape[n]&&G(),s=[],0!==p[n]&&!e.empty())for(c=e.getPrototype(),h=e.offset,f=he([0],p.length);;){for(l=null!=a[f[n]]?e.data[h+a[f[n]]*e.stride[n]]:c,s.push(l),i=p.length-1;i>=0&&f[i]+1===p[i];)i!==n&&(h-=e.stride[i]*f[i]),f[i--]=0;if(i<0)break;i!==n&&(h+=e.stride[i]),f[i]++}return new t(s,p)},m({"○":oe({monad:te((function(e){return Math.PI*e}),(function(e){return new o(Math.PI*e.re,Math.PI*e.im)})),dyad:function(e,t){var r,n,a;if("number"==typeof e)switch(t){case-12:return o.exp(ye(0,e));case-11:return ye(0,e);case-10:case-9:return e;case-8:return ye(0,-Math.sqrt(1+e*e));case-7:return o.atanh(e);case-6:return o.acosh(e);case-5:return o.asinh(e);case-4:return a=o.sqrt(e*e-1),e<-1?-a:a;case-3:return o.atan(e);case-2:return o.acos(e);case-1:return o.asin(e);case 0:return o.sqrt(1-e*e);case 1:return Math.sin(e);case 2:return Math.cos(e);case 3:return Math.tan(e);case 4:return Math.sqrt(1+e*e);case 5:return.5*((r=Math.exp(e))-(n=1/r));case 6:return.5*((r=Math.exp(e))+(n=1/r));case 7:return((r=Math.exp(e))-(n=1/r))/(r+n);case 8:return o.sqrt(-1-e*e);case 9:return e;case 10:return Math.abs(e);case 11:case 12:return 0;default:return q("Unknown circular or hyperbolic function "+t)}else{if(!(e instanceof o))return q();switch(t){case-12:return o.exp(ye(-e.im,e.re));case-11:return o.itimes(e);case-10:return o.conjugate(e);case-9:return e;case-8:return a=o.subtract(-1,o.multiply(e,e)),o.negate(o.sqrt(a));case-7:return o.atanh(e);case-6:return o.acosh(e);case-5:return o.asinh(e);case-4:return-1===e.re&&0===e.im?0:(r=o.add(e,1),n=o.subtract(e,1),o.multiply(r,o.sqrt(o.divide(n,r))));case-3:return o.atan(e);case-2:return o.acos(e);case-1:return o.asin(e);case 0:return o.sqrt(o.subtract(1,o.multiply(e,e)));case 1:return o.sin(e);case 2:return o.cos(e);case 3:return o.tan(e);case 4:return o.sqrt(o.add(1,o.multiply(e,e)));case 5:return o.sinh(e);case 6:return o.cosh(e);case 7:return o.tanh(e);case 8:return o.sqrt(o.subtract(-1,o.multiply(e,e)));case 9:return e.re;case 10:return o.magnitude(e);case 11:return e.im;case 12:return o.direction(e);default:return q("Unknown circular or hyperbolic function "+t)}}}})}),m({",":function(e,r,n){var o,a,s,c,i,f,h,p,u,l,g,y,d,w,v,m,b,D,A,E,M,x,k;if(r){if(c=Math.max(r.shape.length,e.shape.length),n?("number"!=typeof(n=n.unwrap())&&q(),!c||0<=n&&n<c||ie()):n=c-1,r.shape.length===(x=e.shape.length)&&0===x)return new t([r.unwrap(),e.unwrap()]);if(r.shape.length?e.shape.length?r.shape.length+1===e.shape.length?((v=n)!==~~v&&ie(),(g=r.shape.slice(0)).splice(n,0,1),(y=r.stride.slice(0)).splice(n,0,0),r=new t(r.data,g,y,r.offset)):r.shape.length===e.shape.length+1?((m=n)!==~~m&&ie(),(g=e.shape.slice(0)).splice(n,0,1),(y=e.stride.slice(0)).splice(n,0,0),e=new t(e.data,g,y,e.offset)):r.shape.length!==e.shape.length&&ie():(l=r.shape.slice(0),(w=n)===~~w&&(l[n]=1),e=new t([e.unwrap()],l,he([0],r.shape.length))):(l=e.shape.slice(0),(d=n)===~~d&&(l[n]=1),r=new t([r.unwrap()],l,he([0],e.shape.length))),r.shape.length!==e.shape.length)throw Error('"assert ⍴⍴(⍺) is ⍴⍴(⍵)" at src/vocabulary/comma.coffee:59');for(s=E=0,k=r.shape.length;0<=k?E<k:E>k;s=0<=k?++E:--E)s!==n&&r.shape[s]!==e.shape[s]&&G();for(g=r.shape.slice(0),(b=n)===~~b?g[n]+=e.shape[n]:g.splice(Math.ceil(n),0,2),a=Array(ce(g)),(y=Array(g.length))[g.length-1]=1,s=M=g.length-2;M>=0;s=M+=-1)y[s]=y[s+1]*g[s+1];if((D=n)===~~D?u=y:(u=y.slice(0)).splice(Math.ceil(n),1),!r.empty())for(p=0,i=r.offset,f=he([0],r.shape.length);;){for(a[p]=r.data[i],o=f.length-1;o>=0&&f[o]+1===r.shape[o];)i-=f[o]*r.stride[o],p-=f[o]*u[o],f[o--]=0;if(o<0)break;i+=r.stride[o],p+=u[o],f[o]++}if(!e.empty())for(p=(A=n)===~~A?y[n]*r.shape[n]:y[Math.ceil(n)],h=e.offset,f=he([0],e.shape.length);;){for(a[p]=e.data[h],o=f.length-1;o>=0&&f[o]+1===e.shape[o];)h-=f[o]*e.stride[o],p-=f[o]*u[o],f[o--]=0;if(o<0)break;h+=e.stride[o],p+=u[o],f[o]++}return new t(a,g,y)}return new t(e.toArray())}}),m({"=":xe(1,oe({dyad:z=function(e,t){return t instanceof o&&e instanceof o?+(t.re===e.re&&t.im===e.im):+(t===e)}})),"≠":xe(0,oe({dyad:function(e,t){return 1-z(e,t)}})),"<":xe(0,oe({dyad:function(e,t,r){return"number"!=typeof e||null!=t&&"number"!=typeof t?q():+(t<e)}})),">":xe(0,oe({dyad:function(e,t,r){return"number"!=typeof e||null!=t&&"number"!=typeof t?q():+(t>e)}})),"≤":xe(1,oe({dyad:function(e,t,r){return"number"!=typeof e||null!=t&&"number"!=typeof t?q():+(t<=e)}})),"≥":xe(1,oe({dyad:function(e,t,r){return"number"!=typeof e||null!=t&&"number"!=typeof t?q():+(t>=e)}})),"≡":function(e,r){return r?t.bool[+Z(e,r)]:new t([C(e)],[])}}),C=function(e){var r,n,o,a,s,c,i,f,h,p,u,l;if(e instanceof t){if(!(e.shape.length||e.data[0]instanceof t))return 0;if(r=0,!(n=e).empty()){for(a=n.data,s=n.shape,c=n.stride,i=s.length-1,h=n.offset,f=[],u=0,l=s.length;u<l;u+=1)f.push(0);for(;;){for(p=a[h],r=Math.max(r,C(p)),o=i;o>=0&&f[o]+1===s[o];)h-=f[o]*c[o],f[o--]=0;if(o<0)break;f[o]++,h+=c[o]}}return r+1}return 0},m({"∘":O((function(e,t){if("function"==typeof t)return"function"==typeof e?function(r,n){return t(e(r),n)}:function(r,n){if(null!=n)throw Error('"assert not ⍺?" at src/vocabulary/compose.coffee:20');return t(e,r)};if("function"!=typeof e)throw Error("\"assert typeof g is 'function'\" at src/vocabulary/compose.coffee:23");return function(r,n){if(null!=n)throw Error('"assert not ⍺?" at src/vocabulary/compose.coffee:25');return e(r,t)}}))}),m({"∪":function(e,r){var n,o,a,s,c,i,f,h,p,u,l,g,y,d,w,v,m,b,D,A,E,M,x,k,R,S;if(r){for(o=[],A=0,x=(k=[r,e]).length;A<x;A++)if((n=k[A]).shape.length>1&&ie(),!(a=n).empty()){for(c=a.data,i=a.shape,f=a.stride,h=i.length-1,u=a.offset,p=[],E=0,R=i.length;E<R;E+=1)p.push(0);for(;;){for(D=c[u],L(o,D)||o.push(D),s=h;s>=0&&p[s]+1===i[s];)u-=p[s]*f[s],p[s--]=0;if(s<0)break;p[s]++,u+=f[s]}}return new t(o)}if(o=[],!(l=e).empty()){for(y=l.data,d=l.shape,w=l.stride,v=d.length-1,b=l.offset,m=[],M=0,S=d.length;M<S;M+=1)m.push(0);for(;;){for(D=y[b],L(o,D)||o.push(D),g=v;g>=0&&m[g]+1===d[g];)b-=m[g]*w[g],m[g--]=0;if(g<0)break;m[g]++,b+=w[g]}}return new t(o)},"∩":function(e,r){var n,o,a,s,c,i;if(r){for(o=[],n=e.toArray(),s=0,c=(i=r.toArray()).length;s<c;s++)a=i[s],L(n,a)&&o.push(a);return new t(o)}return Q()}}),L=function(e,t){var r,n,o;if(!(e instanceof Array))throw Error('"assert a instanceof Array" at src/vocabulary/cupcap.coffee:56');for(n=0,o=e.length;n<o;n++)if(r=e[n],Z(t,r))return!0;return!1},m({"⊥":function(e,r){var n,o,a,s,c,i,f,h,p,u,l,g,y,d,w,v,m;if(!r)throw Error('"assert ⍺" at src/vocabulary/decode.coffee:53');for(r.shape.length||(r=new t([r.unwrap()])),e.shape.length||(e=new t([e.unwrap()])),h=r.shape[r.shape.length-1],s=e.shape[0],1!==h&&1!==s&&h!==s&&G(),n=r.toArray(),o=e.toArray(),a=[],c=g=0,w=n.length/h;0<=w?g<w:g>w;c=0<=w?++g:--g)for(i=y=0,v=o.length/s;0<=v?y<v:y>v;i=0<=v?++y:--y){for(p=n.slice(c*h,(c+1)*h),u=function(){var e,t;for(t=[],f=e=0;0<=s?e<s:e>s;f=0<=s?++e:--e)t.push(o[i+f*(o.length/s)]);return t}(),1===p.length&&(p=function(){var e,t,r;for(r=[],e=0,t=u.length;0<=t?e<t:e>t;0<=t?e++:e--)r.push(p[0]);return r}()),1===u.length&&(u=function(){var e,t,r;for(r=[],e=0,t=p.length;0<=t?e<t:e>t;0<=t?e++:e--)r.push(u[0]);return r}()),l=u[0],f=d=1,m=u.length;1<=m?d<m:d>m;f=1<=m?++d:--d)l=l*p[f]+u[f];a.push(l)}return new t(a,r.shape.slice(0,-1).concat(e.shape.slice(1)))}}),m({".":O((function(e,t){return t===Me["∘"]?re(e):V(e,t)}))}),re=function(e){if("function"!=typeof e)throw Error("\"assert typeof f is 'function'\" at src/vocabulary/dot.coffee:39");return function(r,n){var o,a,s,c,i,f,h,p,u,l;for(n||me("Adverb ∘. (Outer product) can be applied to dyadic verbs only"),o=n.toArray(),a=r.toArray(),s=[],h=0,u=o.length;h<u;h++)for(c=o[h],p=0,l=a.length;p<l;p++)i=a[p],c instanceof t||(c=t.scalar(c)),i instanceof t||(i=t.scalar(i)),(f=e(i,c)).shape.length||(f=f.unwrap()),s.push(f);return new t(s,n.shape.concat(r.shape))}},V=function(e,r){var n,o;return n=Me["¨"](fe(r)),o=re(e),function(e,r){return r.shape.length||(r=new t([r.unwrap()])),e.shape.length||(e=new t([e.unwrap()])),n(o(Me["⊂"](e,void 0,new t([0])),Me["⊂"](r,void 0,new t([r.shape.length-1]))))}},m({"↓":function(e,r,n){var o,a,s,c,i,f,h,p,u,l,g,y,d,w,v,m;if(r){for(r.shape.length>1&&ie(),y=0,v=(o=r.toArray()).length;y<v;y++)(l=g=o[y])!==~~l&&q();for(e.shape.length?o.length>e.shape.length&&ie():e=new t(e.data,he([1],o.length),he([0],o.length),e.offset),u=e.shape.slice(0),h=e.offset,c=d=0,m=o.length;d<m;c=++d)g=o[c],u[c]=Math.max(0,e.shape[c]-Math.abs(g)),g>0&&(h+=g*e.stride[c]);return 0===ce(u)?new t([],u):new t(e.data,u,e.stride,h)}for(e.shape.length||Q("Split of scalar not implemented"),f=(p=e.shape.slice(0,e.shape.length-1)).reduce((function(e,t){return e*t}),1),i=e.shape[e.shape.length-1],a=e.toArray(),s=[],c=w=0;0<=f?w<f:w>f;c=0<=f?++w:--w)h=c*i,s.push(new t(a.slice(h,h+i)));return new t(s,p)}}),m({"¨":b((function(e,r){if("function"!=typeof e)throw Error("\"assert typeof f is 'function'\" at src/vocabulary/each.coffee:18");if(void 0!==r)throw Error("\"assert typeof g is 'undefined'\" at src/vocabulary/each.coffee:19");return function(r,n){var o,a;return n?R(n.shape,r.shape)?r.map2(n,(function(r,n){var o;if(r instanceof t||(r=new t([r],[])),n instanceof t||(n=new t([n],[])),!((o=e(r,n))instanceof t))throw Error('"assert r instanceof APLArray" at src/vocabulary/each.coffee:32');return o.shape.length?o:o.unwrap()})):n.isSingleton()?(a=n.data[0]instanceof t?n.unwrap():n,r.map((function(r){var n;if(r instanceof t||(r=new t([r],[])),!((n=e(r,a))instanceof t))throw Error('"assert r instanceof APLArray" at src/vocabulary/each.coffee:39');return n.shape.length?n:n.unwrap()}))):r.isSingleton()?(o=r.data[0]instanceof t?r.unwrap():r,n.map((function(r){var n;if(r instanceof t||(r=new t([r],[])),!((n=e(o,r))instanceof t))throw Error('"assert r instanceof APLArray" at src/vocabulary/each.coffee:46');return n.shape.length?n:n.unwrap()}))):G():r.map((function(r){var n;if(r instanceof t||(r=new t([r],[])),!((n=e(r))instanceof t))throw Error('"assert r instanceof APLArray" at src/vocabulary/each.coffee:25');return n.shape.length?n:n.unwrap()}))}}))}),m({"⊤":function(e,r){var n,o,a,s,c,i,f,h,p,u,l,g,y,d,w;if(!r)throw Error('"assert ⍺" at src/vocabulary/encode.coffee:40');for(n=r.toArray(),o=e.toArray(),p=r.shape.concat(e.shape),a=Array(ce(p)),h=r.shape.length?r.shape[0]:1,f=n.length/h,s=g=0;0<=f?g<f:g>f;s=0<=f?++g:--g)for(c=y=0,w=o.length;y<w;c=++y)for((l=o[c])<0&&(l=-l),i=d=h-1;d>=0;i=d+=-1)0===(u=n[i*f+s])?(a[(i*f+s)*o.length+c]=l,l=0):(a[(i*f+s)*o.length+c]=l%u,l=Math.round((l-l%u)/u));return new t(a,p)}}),m({"∊":D("∈",(function(e,r){var n,o;return r?(n=e.toArray(),r.map((function(e){var t,r,o;for(r=0,o=n.length;r<o;r++)if(t=n[r],Z(e,t))return 1;return 0}))):(U(e,o=[]),new t(o))}))}),U=function(e,r){var n,o,a,s,c,i,f,h,p,u,l,g;if(!(e instanceof t))return r.push(e);if(!(f=e).empty()){for(n=f.data,o=f.shape,a=f.stride,s=o.length-1,i=f.offset,c=[],u=0,l=o.length;u<l;u+=1)c.push(0);for(g=[];;){for(p=n[i],U(p,r),h=s;h>=0&&c[h]+1===o[h];)i-=c[h]*a[h],c[h--]=0;if(h<0)break;c[h]++,g.push(i+=a[h])}return g}},m({"!":xe(1,oe({monad:function(e,t,r){var n;return"number"!=typeof e||null!=t&&"number"!=typeof t?q():(n=e)!==~~n?ke(e+1):e<0?q():e<de.length?de[e]:Math.round(ke(e+1))},dyad:r=function(e,t,n){var o,a,s;return"number"!=typeof e||null!=t&&"number"!=typeof t?q():(o=function(){switch(4*Y(t)+2*Y(e)+Y(e-t)){case 0:return Math.exp(W(e+1)-W(t+1)-W(e-t+1));case 1:return 0;case 2:return q();case 3:return Math.pow(-1,t)*r(t-e-1,t);case 4:return 0;case 5:break;case 6:return Math.pow(-1,e-t)*r(Math.abs(t+1),Math.abs(e+1));case 7:return 0}}(),(a=e)===~~a&&(s=t)===~~s?Math.round(o):o)}}))}),Y=function(e){var t;return(t=e)===~~t&&e<0},de=[Le=1].concat(function(){var e,t;for(t=[],Oe=e=1;e<=25;Oe=++e)t.push(Le*=Oe);return t}()),Pe=[.9999999999998099,676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,1.5056327351493116e-7],je=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22],Ne={"lnΓ":function(e){var t,r,n,o;if(e<0)return NaN;for(n=je[0],t=o=je.length-1;o>0;t=o+=-1)n+=je[t]/(e+t);return r=e+4.7421875+.5,.5*Math.log(2*Math.PI)+(e+.5)*Math.log(r)-r+Math.log(n)-Math.log(e)},"Γ":function(e){var t,r,n,o;if(e<.5)return Math.PI/(Math.sin(Math.PI*e)*ke(1-e));if(e>100)return Math.exp(W(e));for(e--,n=Pe[0],t=o=1;o<9;t=o+=1)n+=Pe[t]/(e+t);return r=e+7+.5,Math.sqrt(2*Math.PI)*Math.pow(r,e+.5)*Math.exp(-r)*n}},ke=Ne.Γ,W=Ne.lnΓ,m({"⍎":function(e,t){var r,n,o,a,s,c,i,f,h,p,u,l;if(t)return Q();if(n="",!(o=e).empty()){for(s=o.data,c=o.shape,i=o.stride,f=c.length-1,p=o.offset,h=[],u=0,l=c.length;u<l;u+=1)h.push(0);for(;;){for("string"!=typeof(r=s[p])&&q(),n+=r,a=f;a>=0&&h[a]+1===c[a];)p-=h[a]*i[a],h[a--]=0;if(a<0)break;h[a]++,p+=i[a]}}return F(n)}}),m({"⍷":function(e,r){var n,o,a,s,c,i,f,h,p,u,l;if(r){if(r.shape.length>e.shape.length)return new t([0],e.shape,he([0],e.shape.length));if(r.shape.length<e.shape.length&&(r=new t(r.data,he([1],e.shape.length-r.shape.length).concat(r.shape),he([0],e.shape.length-r.shape.length).concat(r.stride),r.offset)),0===ce(r.shape))return new t([1],e.shape,he([0],e.shape.length));for(s=[],c=u=0,l=e.shape.length;0<=l?u<l:u>l;c=0<=l?++u:--u){if((o=e.shape[c]-r.shape[c]+1)<=0)return new t([0],e.shape,he([0],e.shape.length));s.push(o)}for(p=ve(e.shape),a=he([0],ce(e.shape)),f=e.offset,h=0,i=he([0],s.length);;){for(a[h]=+Z(r,new t(e.data,r.shape,e.stride,f)),n=s.length-1;n>=0&&i[n]+1===s[n];)f-=i[n]*e.stride[n],h-=i[n]*p[n],i[n--]=0;if(n<0)break;f+=e.stride[n],h+=p[n],i[n]++}return new t(a,e.shape)}return Q()}}),m({"⌊":xe(1/0,oe({monad:o.floor,dyad:function(e,t,r){return"number"!=typeof e||null!=t&&"number"!=typeof t?q():Math.min(e,t)}})),"⌈":xe(-1/0,oe({monad:o.ceil,dyad:function(e,t,r){return"number"!=typeof e||null!=t&&"number"!=typeof t?q():Math.max(e,t)}}))}),m({_fork1:function(e,t){if("function"!=typeof e)throw Error("\"assert typeof h is 'function'\" at src/vocabulary/fork.coffee:20");if("function"!=typeof t)throw Error("\"assert typeof g is 'function'\" at src/vocabulary/fork.coffee:21");return[e,t]},_fork2:function(e,t){var r,n;if(n=e[0],r=e[1],"function"!=typeof n)throw Error("\"assert typeof h is 'function'\" at src/vocabulary/fork.coffee:25");return function(e,o){return r(n(e,o),t(e,o))}}}),m({"⍕":function(e,r){var n;return r?Q():(n=T(e),new t(n.join(""),[n.length,n[0].length]))}}),T=function(e){var r,n,o,a,s,c,i,f,h,p,u,l,g,y,d,w,v,m,b,D,A,E,M,x,k,R,S,_,N,I,O,L,P,j,C,q,U;if(void 0===e)return["undefined"];if(null===e)return["null"];if("string"==typeof e)return[e];if("number"==typeof e)return(g=[(""+e).replace("Infinity","∞").replace(/-/g,"¯")]).align="right",g;if("function"==typeof e)return["λ"];if(e instanceof t){if(0===ce(e.shape))return[""];if(v=e.shape,e=e.toArray(),!v.length)return T(e[0]);for(l=ce(v.slice(0,v.length-1)),u=v[v.length-1],w=function(){var e,t;for(t=[],e=0;0<=l?e<l:e>l;0<=l?e++:e--)t.push({height:0,bottomMargin:0});return t}(),a=function(){var e,t;for(t=[],e=0;0<=u?e<u:e>u;0<=u?e++:e--)t.push({type:0,width:0,leftMargin:0,rightMargin:0});return t}(),c=function(){var r,s,c;for(c=[],i=r=0,s=w.length;r<s;i=++r)g=w[i],c.push(function(){var r,s,c;for(c=[],f=r=0,s=a.length;r<s;f=++r)o=a[f],D=e[u*i+f],n=T(D),g.height=Math.max(g.height,n.length),o.width=Math.max(o.width,n[0].length),o.type=Math.max(o.type,"string"==typeof D&&1===D.length?0:D instanceof t?2:1),c.push(n);return c}());return c}(),m=1,s=A=v.length-2;A>=1;s=A+=-1)for(m*=v[s],i=E=m-1,L=l-1;m>0?E<L:E>L;i=E+=m)w[i].bottomMargin++;for(f=M=0,k=a.length;M<k;f=++M)o=a[f],f===u-1||o.type===(P=a[f+1].type)&&0===P||o.rightMargin++,2===o.type&&(o.leftMargin++,o.rightMargin++);for(y=[],i=x=0,R=w.length;x<R;i=++x){for(g=w[i],f=_=0,S=a.length;_<S;f=++_){for(o=a[f],"right"===(b=c[i][f]).align?(p=he(" ",o.leftMargin+o.width-b[0].length),d=he(" ",o.rightMargin)):(p=he(" ",o.leftMargin),d=he(" ",o.rightMargin+o.width-b[0].length)),h=N=0,j=b.length;0<=j?N<j:N>j;h=0<=j?++N:--N)b[h]=p+b[h]+d;for(r=he(" ",b[0].length),I=C=b.length,q=g.height+g.bottomMargin;C<=q?I<q:I>q;C<=q?I++:I--)b.push(r)}for(h=O=0,U=g.height+g.bottomMargin;0<=U?O<U:O>U;h=0<=U?++O:--O)y.push(function(){var e,t;for(t=[],f=e=0;0<=u?e<u:e>u;f=0<=u?++e:--e)t.push(c[i][f][h]);return t}().join(""))}return y}return[""+e]},m({"⍋":function(e,t){return H(e,t,1)},"⍒":function(e,t){return H(e,t,-1)}}),H=function(e,r,n){var o,a,s,c,i,f,h,p,u,l,g,y,d;if(o={},r&&(r.shape.length||ie(),o={},!(s=r).empty())){for(i=s.data,f=s.shape,h=s.stride,p=f.length-1,u=s.offset,a=[],g=0,y=f.length;g<y;g+=1)a.push(0);for(;;){for("string"!=typeof(l=i[u])&&q(),o[l]=a[a.length-1],c=p;c>=0&&a[c]+1===f[c];)u-=a[c]*h[c],a[c--]=0;if(c<0)break;a[c]++,u+=h[c]}}return e.shape.length||ie(),new t(function(){d=[];for(var t=0,r=e.shape[0];0<=r?t<r:t>r;0<=r?t++:t--)d.push(t);return d}.apply(this).sort((function(t,r){var s,c,i,f,h;for(c=e.offset,a=he([0],e.shape.length);;){if(l=e.data[c+t*e.stride[0]],h=e.data[c+r*e.stride[0]],(i=typeof l)<(f=typeof h))return-n;if(i>f)return n;if(null!=o[l]&&(l=o[l]),null!=o[h]&&(h=o[h]),l<h)return-n;if(l>h)return n;for(s=a.length-1;s>0&&a[s]+1===e.shape[s];)c-=e.stride[s]*a[s],a[s--]=0;if(s<=0)break;c+=e.stride[s],a[s]++}return 0})))},m({"⍁":O((function(e,r){var n;if(e instanceof t&&(e=(n=[r,e])[0],r=n[1]),"function"!=typeof e)throw Error("\"assert typeof f is 'function'\" at src/vocabulary/identity.coffee:13");if(!(r instanceof t))throw Error('"assert x instanceof APLArray" at src/vocabulary/identity.coffee:14');return r.isSingleton()||ie(),r.shape.length&&(r=t.scalar(r.unwrap())),xe(r,(function(t,r,n){return e(t,r,n)}))}))}),m({"⍳":function(e,r){var n,o,a,s,c,i,f,h,p,u,l,g,y,d,w,v,m,b,D,A,E,M,x,k,R,S,_,N,I,O,L,P;if(r)return 1!==r.shape.length&&ie(),e.map((function(e){var n,o,a,s,c,i,f,h,p,u,l,g,y;try{if(a=r.shape,!(s=r).empty()){for(i=s.data,f=s.shape,h=s.stride,p=f.length-1,u=s.offset,o=[],g=0,y=f.length;g<y;g+=1)o.push(0);for(;;){if(l=i[u],Z(e,l))throw a=o,"break";for(c=p;c>=0&&o[c]+1===f[c];)u-=o[c]*h[c],o[c--]=0;if(c<0)break;o[c]++,u+=h[c]}}}catch(e){if("break"!==(n=e))throw n}return 1===a.length?a[0]:new t(a)}));for(e.shape.length>1&&ie(),E=0,R=(n=e.toArray()).length;E<R;E++)(D=n[E])===~~D&&0<=D||q();if(p=ce(n))if(1===n.length)for(o=p<=256?new Uint8Array(p):p<=65536?new Uint16Array(p):p<=4294967296?new Uint32Array(p):q(),a=M=0;M<p;a=M+=1)o[a]=a;else{for(s=new((h=Math.max.apply(Math,n))<=256?Uint8Array:h<=65536?Uint16Array:h<=4294967296?Uint32Array:q())(p*n.length),A=p,a=x=0,I=n.length;x<I;a=x+=1){for(A/=n[a],u=p*a,f=k=0,O=n[a];k<O;f=k+=1){if(s[u]=f,g=u,y=1,d=A,(l=s)instanceof Array)for(f=S=y,L=d;S<L;f=S+=1)l[g+f]=l[g+f%y];else{for(l=l.subarray(g,g+d);2*y<d;)l.set(l.subarray(0,y),y),y*=2;l.set(l.subarray(0,d-y),y)}u+=A}if(w=s,v=p*a,m=n[a]*A,b=p,w instanceof Array)for(f=_=m,P=b;_<P;f=_+=1)w[v+f]=w[v+f%m];else{for(w=w.subarray(v,v+b);2*m<b;)w.set(w.subarray(0,m),m),m*=2;w.set(w.subarray(0,b-m),m)}}for(o=[],c=[n.length],i=[p],a=N=0;N<p;a=N+=1)o.push(new t(s,c,i,a))}else o=[];return new t(o,n)}}),m({"⊂":function(e,r,n){var o,a,s,c,i,f,h,p,u,l,g,y,d,w,v,m,b,D;if(r)throw Error('"assert not ⍺" at src/vocabulary/leftshoe.coffee:13');if(n=null!=n?$(n,e.shape.length):function(){D=[];for(var t=0,r=e.shape.length;0<=r?t<r:t>r;0<=r?t++:t--)D.push(t);return D}.apply(this),e.isSimple())return e;if(w=function(){var t,r,o;for(o=[],t=0,r=n.length;t<r;t++)a=n[t],o.push(e.shape[a]);return o}(),v=function(){var t,r,o;for(o=[],t=0,r=n.length;t<r;t++)a=n[t],o.push(e.stride[a]);return o}(),i=function(){var t,r,o;for(o=[],a=t=0,r=e.shape.length;0<=r?t<r:t>r;a=0<=r?++t:--t)qe.call(n,a)<0&&o.push(a);return o}(),f=function(){var t,r,n;for(n=[],t=0,r=i.length;t<r;t++)a=i[t],n.push(e.shape[a]);return n}(),h=function(){var t,r,n;for(n=[],t=0,r=i.length;t<r;t++)a=i[t],n.push(e.stride[a]);return n}(),o=[],!(p=new t(e.data,f,h,e.offset)).empty()){for(l=p.data,g=p.shape,y=p.stride,d=g.length-1,c=p.offset,s=[],m=0,b=g.length;m<b;m+=1)s.push(0);for(;;){for(l[c],o.push(new t(e.data,w,v,c)),u=d;u>=0&&s[u]+1===g[u];)c-=s[u]*y[u],s[u--]=0;if(u<0)break;s[u]++,c+=y[u]}}return new t(o,f)}}),m({"~":oe({monad:function(e){return+!S(e)}}),"∨":xe(0,oe({dyad:function(e,t){return o.isint(t)&&o.isint(e)||q("∨ is implemented only for Gaussian integers"),o.gcd(t,e)}})),"∧":D("^",xe(1,oe({dyad:function(e,t){return o.isint(t)&&o.isint(e)||q("∧ is implemented only for Gaussian integers"),o.lcm(t,e)}}))),"⍱":oe({dyad:function(e,t,r){return"number"!=typeof e||null!=t&&"number"!=typeof t?q():+!(S(t)|S(e))}}),"⍲":oe({dyad:function(e,t,r){return"number"!=typeof e||null!=t&&"number"!=typeof t?q():+!(S(t)&S(e))}})}),m({"⍣":O((function(e,r){var n,o;if(r instanceof t&&"function"==typeof e)n=r,r=e,e=n;else if("function"!=typeof r)throw Error("\"assert typeof f is 'function'\" at src/vocabulary/poweroperator.coffee:15");return"function"==typeof e?function(t,n){for(var o;;){if(o=r(t,n),e(t,o).toBool())return t;t=o}}:(o=e.toInt(0),function(e,t){var n;for(n=0;0<=o?n<o:n>o;0<=o?n++:n--)e=r(e,t);return e})}))}),m({"get_⎕":function(){return"function"==typeof("undefined"!=typeof window&&null!==window?window.prompt:void 0)?new t(prompt("⎕:")||""):Q("Reading from ⎕ is not implemented.")},"set_⎕":function(e){var t;return t=T(e).join("\n")+"\n","function"==typeof("undefined"!=typeof window&&null!==window?window.alert:void 0)?window.alert(t):process.stdout.write(t),e},"get_⍞":function(){return"function"==typeof("undefined"!=typeof window&&null!==window?window.prompt:void 0)?prompt("")||"":Q("Reading from ⍞ is not implemented.")},"set_⍞":function(e){var t;return t=T(e).join("\n"),"function"==typeof("undefined"!=typeof window&&null!==window?window.alert:void 0)?window.alert(t):process.stdout.write(t),e},"get_⎕IO":function(){return t.zero},"set_⎕IO":function(e){return Z(e,t.zero)?e:q("The index origin (⎕IO) is fixed at 0")},"⎕DL":P((function(e,r,n,o){var a;a=+new Date,setTimeout((function(){return o(new t([new Date-a]))}),e.unwrap())})),"⎕RE":function(e,r){var n,o,a,s,c,i,f,h;c=r.toSimpleString(),i=e.toSimpleString();try{a=new RegExp(c)}catch(e){q(e.toString())}if(n=a.exec(i)){for(o=[n.index],f=0,h=n.length;f<h;f++)s=n[f],o.push(new t(s||""));return new t(o)}return t.zilde},"⎕UCS":function(e,t){return null!=t&&Q(),e.map((function(e){var t,r;return(t=e)===~~t&&0<=(r=t)&&r<65536?String.fromCharCode(e):"string"==typeof e?e.charCodeAt(0):q()}))}}),m({"?":function(e,t){return t?j(e,t):ue(e)}}),ue=oe({monad:function(e){var t;return(t=e)===~~t&&1<=t||q(),Math.floor(Math.random()*e)}}),j=function(e,r){var n,o,a,s,c,i,f,h,p;for(r=r.unwrap(),(c=e=e.unwrap())===~~c&&0<=c&&(i=r)===~~i&&0<=(h=i)&&h<e+1||q(),s=function(){p=[];for(var t=0;0<=e?t<e:t>e;0<=e?t++:t--)p.push(t);return p}.apply(this),o=f=0;f<r;o=f+=1)a=o+Math.floor(Math.random()*(e-o)),n=s[o],s[o]=s[a],s[a]=n;return new t(s.slice(0,r))},m({"↗":function(e){return M(e.toString())}}),m({"⍴":function(e,r){var n,o,a,s,c,i,f,h,p,u,l,g,y,d,w,v,m,b;if(r){for(r.shape.length>1&&ie(),w=0,m=(n=r.toArray()).length;w<m;w++)(y=d=n[w])===~~y&&0<=y||q();if(s=ce(n)){if(n.length>=e.shape.length&&R(e.shape,n.slice(n.length-e.shape.length)))return new t(e.data,n,he([0],n.length-e.shape.length).concat(e.stride),e.offset);o=[];try{if(!(c=e).empty()){for(f=c.data,h=c.shape,p=c.stride,u=h.length-1,g=c.offset,l=[],v=0,b=h.length;v<b;v+=1)l.push(0);for(;;){if(d=f[g],o.length>=s)throw"break";for(o.push(d),i=u;i>=0&&l[i]+1===h[i];)g-=l[i]*p[i],l[i--]=0;if(i<0)break;l[i]++,g+=p[i]}}}catch(e){if("break"!==(a=e))throw a}if(o.length){for(;2*o.length<s;)o=o.concat(o);o.length!==s&&(o=o.concat(o.slice(0,s-o.length)))}else o=he([e.getPrototype()],s);return new t(o,n)}return new t([],n)}return new t(e.shape)}}),m({"⌽":le=function(e,r,n){var o,a,s,c,i,f,h,p,u,l,g,y;if(!(void 0===n||n instanceof t))throw Error("\"assert typeof axis is 'undefined' or axis instanceof APLArray\" at src/vocabulary/rotate.coffee:4");if(r){if((l=n=n?n.unwrap():e.shape.length-1)!==~~l&&q(),!e.shape.length||0<=n&&n<e.shape.length||K(),(g=p=r.unwrap())!==~~g&&q(),!p)return e;if(p=((c=e.shape[n])+p%c)%c,e.empty()||0===p)return e;for(a=[],h=e.shape,u=e.stride,f=e.offset,s=he([0],h.length);;){for(a.push(e.data[f+((s[n]+p)%h[n]-s[n])*u[n]]),o=h.length-1;o>=0&&s[o]+1===h[o];)f-=s[o]*u[o],s[o--]=0;if(o<0)break;s[o]++,f+=u[o]}return new t(a,h)}return n?(n.isSingleton()||G(),(y=n=n.unwrap())!==~~y&&q(),0<=n&&n<e.shape.length||K()):n=[e.shape.length-1],0===e.shape.length?e:((u=e.stride.slice(0))[n]=-u[n],i=e.offset+(e.shape[n]-1)*e.stride[n],new t(e.data,e.shape,u,i))},"⊖":function(e,r,n){return null==n&&(n=t.zero),le(e,r,n)}}),m({"/":b((function(e,t,r){return"function"==typeof e?fe(e,t,r):I(e,t,r)})),"⌿":b((function(e,r,n){return null==n&&(n=t.zero),"function"==typeof e?fe(e,r,n):I(e,r,n)}))}),fe=this.reduce=function(e,r,n){if("function"!=typeof e)throw Error("\"assert typeof f is 'function'\" at src/vocabulary/slash.coffee:36");if(void 0!==r)throw Error("\"assert typeof g is 'undefined'\" at src/vocabulary/slash.coffee:37");if(!(void 0===n||n instanceof t))throw Error("\"assert((typeof axis0 is 'undefined') or (axis0 instanceof APLArray))\" at src/vocabulary/slash.coffee:38");return function(r,o){var a,s,c,i,f,h,p,u,l,g,y,d,w,v,m,b;if(r.shape.length||(r=new t([r.unwrap()])),0<=(s=null!=n?n.toInt():r.shape.length-1)&&s<r.shape.length||ie(),o?(p=!0,(u=o.toInt())<0&&(h=!0,u=-u)):(u=r.shape[s],!0),(y=r.shape.slice(0))[s]=r.shape[s]-u+1,g=y,p){if(0===y[s])return new t([],g);y[s]<0&&G()}else(g=g.slice(0)).splice(s,1);if(r.empty()){if(null!=(v=e.identity)){if(v.shape.length)throw Error('"assert !⍴⍴ z" at src/vocabulary/slash.coffee:66');return new t(v.data,g,he([0],g.length),v.offset)}q()}for(c=[],f=he([0],y.length),l=r.offset;;){if(h)for(d=(d=r.data[l])instanceof t?d:t.scalar(d),i=m=1;m<u;i=m+=1)w=(w=r.data[l+i*r.stride[s]])instanceof t?w:t.scalar(w),d=e(d,w);else for(d=(d=r.data[l+(u-1)*r.stride[s]])instanceof t?d:t.scalar(d),i=b=u-2;b>=0;i=b+=-1)w=(w=r.data[l+i*r.stride[s]])instanceof t?w:t.scalar(w),d=e(d,w);for(d.shape.length||(d=d.unwrap()),c.push(d),a=f.length-1;a>=0&&f[a]+1===y[a];)l-=f[a]*r.stride[a],f[a--]=0;if(a<0)break;l+=r.stride[a],f[a]++}return new t(c,g)}},I=function(e,r,n){var o,a,s,c,i,f,h,p,u,l,g,y,d,w,v;for(e.shape.length||(e=new t([e.unwrap()])),n=n?n.toInt(0,e.shape.length):e.shape.length-1,r.shape.length>1&&ie(),o=r.toArray(),h=e.shape[n],1===o.length&&(o=he(o,h)),1!==h&&h!==o.length&&G(),(u=e.shape.slice(0))[n]=0,a=[],i=y=0,w=o.length;y<w;i=++y)for((l=g=o[i])!==~~l&&q(),u[n]+=Math.abs(g),d=0,v=Math.abs(g);0<=v?d<v:d>v;0<=v?d++:d--)a.push(g>0?i:null);if(1===h&&(a=function(){var e,t,r;for(r=[],e=0,t=a.length;e<t;e++)g=a[e],r.push(null!=g?0:g);return r}()),s=[],0!==u[n]&&!e.empty())for(c=e.getPrototype(),p=e.offset,f=he([0],u.length);;){for(g=null!=a[f[n]]?e.data[p+a[f[n]]*e.stride[n]]:c,s.push(g),i=u.length-1;i>=0&&f[i]+1===u[i];)i!==n&&(p-=e.stride[i]*f[i]),f[i--]=0;if(i<0)break;i!==n&&(p+=e.stride[i]),f[i]++}return new t(s,u)},m({"⌷":we=function(e,r,n){var o,a,s,c,i,f,h,p,u,l,g;if("function"==typeof e)return function(t,n){return e(t,n,r)};if(r||Q(),u=se(e,r,n),i=u[0],c=u[1],a=[],A(function(){var e,t,r;for(r=[],e=0,t=i.length;e<t;e++)h=i[e],r.push(h.length);return r}())){for(f=he([0],i.length),s=e.offset,o=p=0,l=i.length;p<l;o=p+=1)s+=i[o][0]*e.stride[o];for(;;){for(a.push(e.data[s]),o=i.length-1;o>=0&&f[o]+1===i[o].length;)s+=(i[o][0]-i[o][f[o]])*e.stride[o],f[o--]=0;if(o<0)break;s+=(i[o][f[o]+1]-i[o][f[o]])*e.stride[o],f[o]++}}return new t(a,(g=[]).concat.apply(g,c))},_index:function(e,t){var r,n,o;return r=(o=e.toArray())[0],n=o[1],we(t,r,n)},_substitute:function(e){var r,n,o,a,s,c,i,f,h,p,u,l,g,y,d,w,v,m,b,D,A,E;if(y=(b=function(){var r,n,o,a;for(a=[],r=0,n=(o=e.toArray()).length;r<n;r++)(d=o[r])instanceof t?a.push(d):a.push(new t([d],[]));return a}())[0],n=b[1],i=b[2],o=b[3],l=(D=se(i,n,o))[0],u=D[1],s=(A=[]).concat.apply(A,u),y.isSingleton())y=new t([y.unwrap()],s,he([0],s.length));else if(s.length!==y.shape.length)ie();else for(a=w=0,m=s.length;w<m;a=++w)c=s[a],y.shape[a]!==c&&G();for(p=new t(i.toArray(),i.shape),f=0,r=v=0,E=l.length;v<E;r=v+=1){if(0===l[r].length)return p;f+=l[r][0]*p.stride[r]}for(h=y.offset,g=he([0],l.length);;){for(p.data[f]=y.data[h],r=l.length-1;r>=0&&g[r]+1===l[r].length;)f+=(l[r][0]-l[r][g[r]])*p.stride[r],h-=g[r]*y.stride[r],g[r--]=0;if(r<0)break;f+=(l[r][g[r]+1]-l[r][g[r]])*p.stride[r],h+=y.stride[r],g[r]++}return p}}),se=function(e,r,n){var o,a,s,c,i,f,h,p,u,l,g,y,d,w,v,m,b,D;if(!(r instanceof t))throw Error('"assert ⍺ instanceof APLArray" at src/vocabulary/squish.coffee:123');if(!(e instanceof t))throw Error('"assert ⍵ instanceof APLArray" at src/vocabulary/squish.coffee:124');if(!(null==n||n instanceof t))throw Error('"assert (not axes?) or axes instanceof APLArray" at src/vocabulary/squish.coffee:125');for(r.shape.length>1&&ie(),(o=r.toArray()).length>e.shape.length&&G(),n=n?n.toArray():function(){b=[];for(var e=0,t=o.length;0<=t?e<t:e>t;0<=t?e++:e--)b.push(e);return b}.apply(this),o.length!==n.length&&G(),f=Array(e.shape.length),i=Array(e.shape.length),c=l=0,d=n.length;l<d;c=++l)for((h=a=n[c])!==~~h&&q(),0<=a&&a<e.shape.length||ie(),void 0!==f[a]&&ie("Duplicate axis"),s=o[c],f[a]=s instanceof t?s.toArray():[s],i[a]=s instanceof t?s.shape:[],g=0,w=(v=f[a]).length;g<w;g++)(p=u=v[g])!==~~p&&q(),0<=u&&u<e.shape[a]||K();for(c=y=0,m=f.length;y<m;c=y+=1)void 0===f[c]&&(f[c]=function(){D=[];for(var t=0,r=e.shape[c];0<=r?t<r:t>r;0<=r?t++:t--)D.push(t);return D}.apply(this),i[c]=[e.shape[c]]);return[f,i]},m({"↑":function(e,t){return t?be(e,t):X(e)}}),be=function(e,r){var n,o,a,s,c,i,f,h,p,u,l,g,y,d,w,v,m,b,D,A,E,M;for(r.shape.length>1&&ie(),e.shape.length||(e=new t([e.unwrap()],r.shape.length?he([1],r.shape[0]):[1])),(n=r.toArray()).length>e.shape.length&&ie(),d=0,b=n.length;d<b;d++)"number"==typeof(y=n[d])&&y===Math.floor(y)||q();for(f=!1,l=e.shape.slice(0),i=w=0,D=n.length;w<D;i=++w)y=n[i],l[i]=Math.abs(y),l[i]>e.shape[i]&&(f=!0);if(f){for((g=Array(l.length))[g.length-1]=1,i=v=g.length-2;v>=0;i=v+=-1)g[i]=g[i+1]*l[i+1];for(c=he([e.getPrototype()],ce(l)),s=l.slice(0),p=e.offset,u=0,i=m=0,A=n.length;m<A;i=++m)y=n[i],s[i]=Math.min(e.shape[i],Math.abs(y)),y<0&&(y<-e.shape[i]?u-=(y+e.shape[i])*g[i]:p+=(y+e.shape[i])*e.stride[i]);if(ce(s))for(a=he([0],s.length);;){for(c[u]=e.data[p],o=s.length-1;o>=0&&a[o]+1===s[o];)p-=a[o]*e.stride[o],u-=a[o]*g[o],a[o--]=0;if(o<0)break;p+=e.stride[o],u+=g[o],a[o]++}return new t(c,l,g)}for(h=e.offset,i=M=0,E=n.length;M<E;i=++M)(y=n[i])<0&&(h+=(e.shape[i]+y)*e.stride[i]);return new t(e.data,l,e.stride,h)},X=function(e){var r;return(r=e.empty()?e.getPrototype():e.data[e.offset])instanceof t?r:new t([r],[])},m({"⍉":function(e,r){var n,o,a,s,c,i,f,h,p,u,l;if(r){for(r.shape.length>1&&ie(),r.shape.length||(r=new t([r.unwrap()])),o=e.shape.length,r.shape[0]!==o&&G(),a=[],s=[],n=f=0,p=(l=r.toArray()).length;f<p;n=++f)(c=i=l[n])===~~c&&0<=c||q(),i>=o&&ie(),null!=a[i]?(a[i]=Math.min(a[i],e.shape[n]),s[i]+=e.stride[n]):(a[i]=e.shape[n],s[i]=e.stride[n]);for(h=0,u=a.length;h<u;h++)null==a[h]&&ie();return new t(e.data,a,s,e.offset)}return new t(e.data,e.shape.slice(0).reverse(),e.stride.slice(0).reverse(),e.offset)}}),m({"⍠":O((function(e,t){if("function"!=typeof e)throw Error("\"assert typeof f is 'function'\" at src/vocabulary/variant.coffee:8");if("function"!=typeof t)throw Error("\"assert typeof g is 'function'\" at src/vocabulary/variant.coffee:9");return function(r,n,o){return(null!=n?e:t)(r,n,o)}}))}),u=(Ie=[1,2,3,4])[0],v=Ie[1],e=Ie[2],n=Ie[3],F=function(t,r){var o,a,s,c,i,f,h,p,u;for(c in null==r&&(r={}),o=ne(t,r),a=_(o,r),s=[ae.env[0].slice(0)],p=o.vars)f=p[c],s[0][f.slot]=r.ctx[c];for(c in i=Ee({code:a,env:s}),u=o.vars)f=u[c],h=r.ctx[c]=s[0][f.slot],f.category===e&&(h.isAdverb=!0),f.category===n&&(h.isConjunction=!0);return i},pe=function(e){var t,r,n,o;return null===e||"string"==(o=typeof e)||"number"===o||"boolean"===o?JSON.stringify(e):e instanceof Array?"["+function(){var t,r,o;for(o=[],t=0,r=e.length;t<r;t++)n=e[t],o.push(pe(n));return o}().join(",")+"]":e.repr?e.repr():"{"+function(){var n;for(t in n=[],e)r=e[t],n.push(pe(t)+":"+pe(r));return n}().join(",")+"}"},_=function(r,m){var b,D,E,M,k,R,S,_,N,I,O,L;if(null==m&&(m={}),r.scopeDepth=0,r.nSlots=ae.nSlots,r.vars=Object.create(ae.vars),function(){var t,o,a,s,c;for(t in null==m.ctx&&(m.ctx=Object.create(Me)),c=[],s=m.ctx)o=s[t],r.vars[t]||(r.vars[t]=a={category:u,slot:r.nSlots++,scopeDepth:r.scopeDepth},"function"==typeof o||o instanceof Re?(a.category=o.isAdverb?e:o.isConjunction?n:v,/^[gs]et_.*/.test(t)?c.push(r.vars[t.slice(4)]={category:u}):c.push(void 0)):c.push(void 0))}(),D=function(e,t){return me(t,{file:m.file,line:e.startLine,col:e.startCol,aplCode:m.aplCode})},!(v<e&&e<n))throw Error('"assert VERB < ADVERB < CONJUNCTION # we are relying on this ordering below" at src/compiler.coffee:36');for((b=function(t){var r,o,a,s;switch(t[0]){case"B":case":":case"←":case"[":case"{":case".":case"⍬":for(o=v,r=a=1,s=t.length;a<s;r=a+=1)t[r]&&(o=Math.max(o,b(t[r])));return"{"===t[0]?(t.category=o,v):o;case"S":case"N":case"J":return 0;case"X":switch(t[1]){case"⍺⍺":case"⍶":case"∇∇":return e;case"⍵⍵":case"⍹":return n;default:return v}break;default:throw Error('"else assert 0" at src/compiler.coffee:49')}})(r),M=[r];M.length;)for(_=(S=M.shift()).vars,N=function(t){var r,o,a,s,c,i,f,h,p,l,g,y,d,w,b,E,x,k;switch(t.scopeNode=S,t[0]){case":":return f=N(t[1]),N(t[2]),f;case"←":return I(t[1],N(t[2]));case"X":return i=t[1],(null!=(d=h=_["get_"+i])?d.category:void 0)===v?u:(null!=(w=_[i])?w.category:void 0)||Ae("Symbol '"+i+"' is referenced before assignment.",{file:m.file,line:t.startLine,col:t.startCol,aplCode:m.aplCode});case"{":for(s=l=1,b=t.length;1<=b?l<b:l>b;s=1<=b?++l:--l)M.push(J(t[s],{scopeNode:S,scopeDepth:o=S.scopeDepth+1+(t.category!==v),nSlots:3,vars:h=J(Object.create(_),{"⍵":{slot:0,scopeDepth:o,category:u},"∇":{slot:1,scopeDepth:o,category:v},"⍺":{slot:2,scopeDepth:o,category:u}})})),t.category===n?(h["⍵⍵"]=h["⍹"]={slot:0,scopeDepth:o-1,category:v},h["∇∇"]={slot:1,scopeDepth:o-1,category:n},h["⍺⍺"]=h["⍶"]={slot:2,scopeDepth:o-1,category:v}):t.category===e&&(h["⍺⍺"]=h["⍶"]={slot:0,scopeDepth:o-1,category:v},h["∇∇"]={slot:1,scopeDepth:o-1,category:e});return null!=(E=t.category)?E:v;case"S":case"N":case"J":case"⍬":return u;case"[":for(s=g=2,x=t.length;g<x;s=g+=1)t[s]&&N(t[s])!==u&&D(t,"Indices must be nouns.");return N(t[1]);case".":for(r=t.slice(1),a=Array(r.length),s=y=r.length-1;y>=0;s=y+=-1)a[s]=N(r[s]);for(s=0;s<r.length-1;)if(a[s]===(k=a[s+1])&&k===u){for(c=s+2;c<r.length&&a[c]===u;)c++;[].splice.apply(r,[s,c-s].concat([["V"].concat(r.slice(s,c))])),[].splice.apply(a,[s,c-s].concat(u))}else s++;for(s=r.length-2;--s>=0;)a[s+1]!==n||a[s]===u&&a[s+2]===u||([].splice.apply(r,[s,s+3-s].concat([["C"].concat(r.slice(s,s+3))])),[].splice.apply(a,[s,s+3-s].concat(v)),s--);for(s=0;s<r.length-1;)a[s]!==u&&a[s+1]===e?([].splice.apply(r,[s,s+2-s].concat([["A"].concat(r.slice(s,s+2))])),[].splice.apply(a,[s,s+2-s].concat(v))):s++;if(2===a.length&&a[0]!==u&&a[1]!==u&&(r=[["H"].concat(r)],a=[v]),a.length>=3&&a.length%2==1&&A(function(){var e,t,r;for(r=[],e=0,t=a.length;e<t;e++)p=a[e],r.push(p!==u);return r}())&&(r=[["F"].concat(r)],a=[v]),a[a.length-1]!==u)a.length>1&&D(r[a.length-1],"Trailing function in expression");else for(;a.length>1;)2===a.length||a[a.length-3]!==u?([].splice.apply(r,[-2,9e9].concat([["M"].concat(r.slice(-2))])),[].splice.apply(a,[-2,9e9].concat(u))):([].splice.apply(r,[-3,9e9].concat([["D"].concat(r.slice(-3))])),[].splice.apply(a,[-3,9e9].concat(u)));return[].splice.apply(t,[0,9e9].concat(r[0])),J(t,r[0]),a[0];default:throw Error('"assert 0" at src/compiler.coffee:144')}},I=function(e,t){var r,n,o,a,s,c,i;switch(e.scopeNode=S,e[0]){case"X":"∇"===(o=e[1])&&D(e,"Assignment to ∇ is not allowed."),_[o]?_[o].category!==t&&D(e,"Inconsistent usage of symbol '"+o+"', it is assigned both nouns and verbs."):_[o]={scopeDepth:S.scopeDepth,slot:S.nSlots++,category:t};break;case".":for(t===u||D(e,"Strand assignment can be used only for nouns."),n=a=1,c=e.length;a<c;n=a+=1)I(e[n],t);break;case"[":for(t===u||D(e,"Index assignment can be used only for nouns."),I(e[1],t),n=s=2,i=e.length;s<i;n=s+=1)(r=e[n])&&N(r);break;default:D(e,"Invalid LHS node type: "+JSON.stringify(e[0]))}return t},E=O=1,L=S.length;O<L;E=O+=1)N(S[E]);return k=function(e){var r,n,u,y,d,m,b,M,S,N,I,O,L,P,j,C,q,U,z,F,B,J;switch(e[0]){case"B":if(1===e.length)return[h,t.zilde,g];for(r=[],E=q=1,z=e.length;q<z;E=q+=1)r.push.apply(r,k(e[E])),r.push(l);return r[r.length-1]=g,r;case":":return j=k(e[1]),C=k(e[2]),j.concat(i,C.length+2,l,C,g);case"←":return k(e[2]).concat(R(e[1]));case"X":return S=e[1],_=e.scopeNode.vars,(null!=(F=L=_["get_"+S])?F.category:void 0)===v?[h,t.zero,c,L.scopeDepth,L.slot,p]:(L=_[S],[c,L.scopeDepth,L.slot]);case"{":return j=k(e[1]),b=[f,j.length].concat(j),d=function(){switch(e.length){case 2:return b;case 3:return C=k(e[2]),M=[f,C.length].concat(C),L=e.scopeNode.vars["⍠"],M.concat(c,L.scopeDepth,L.slot,b,a);default:return D(e)}}(),e.category!==v?[f,d.length+1].concat(d,g):d;case"S":return y=e[1][0],I=e[1].slice(1,-1).replace(RegExp(""+(y+y),"g"),y),[h,new t(I,1===I.length?[]:void 0)];case"N":return r=function(){var t,r,n,o;for(o=[],t=0,r=(n=e[1].replace(/[¯∞]/g,"-").split(/j/i)).length;t<r;t++)"-"===(j=n[t])?o.push(1/0):"--"===j?o.push(-1/0):j.match(/^-?0x/i)?o.push(parseInt(j,16)):o.push(parseFloat(j));return o}(),L=r[1]?new o(r[0],r[1]):r[0],[h,new t([L],[])];case"J":return d=Function("return function(_w,_a){return("+e[1].replace(/^«|»$/g,"")+")};")(),[s,function(e,t){return x(d(e,t))}];case"[":for(L=e.scopeNode.vars._index,n=[],r=[],E=U=2,B=e.length;U<B;E=U+=1)(u=e[E])&&(n.push(E-2),r.push.apply(r,k(u)));return r.push(w,n.length,h,new t(n),w,2,c,L.scopeDepth,L.slot),r.push.apply(r,k(e[1])),r.push(a),r;case"V":return m=function(){var t,r,n;for(n=[],E=t=1,r=e.length;t<r;E=t+=1)n.push(k(e[E]));return n}(),A(function(){var e,t,r;for(r=[],e=0,t=m.length;e<t;e++)d=m[e],r.push(2===d.length&&d[0]===h);return r}())?[h,new t(function(){var e,t,r;for(r=[],e=0,t=m.length;e<t;e++)d=m[e],r.push((j=d[1]).isSimple()?j.unwrap():j);return r}())]:(J=[]).concat.apply(J,Ce.call(m).concat([w],[e.length-1]));case"⍬":return[h,t.zilde];case"M":return k(e[2]).concat(k(e[1]),p);case"A":return k(e[1]).concat(k(e[2]),p);case"D":case"C":return k(e[3]).concat(k(e[2]),k(e[1]),a);case"H":return L=e.scopeNode.vars._hook,k(e[2]).concat(c,L.scopeDepth,L.slot,k(e[1]),a);case"F":for(O=e.scopeNode.vars._hook,L=e.scopeNode.vars._fork1,P=e.scopeNode.vars._fork2,E=e.length-1,N=k(e[E--]);E>=2;)N=N.concat(c,L.scopeDepth,L.slot,k(e[E--]),a,c,P.scopeDepth,P.slot,k(e[E--]),a);return E?N.concat(k(e[1]),c,O.scopeDepth,O.slot,a):N;default:throw Error('"else assert 0" at src/compiler.coffee:300')}},R=function(e){var r,n,o,a,s,i,f,u,g,m,b;switch(e[0]){case"X":return s=e[1],(null!=(g=i=(_=e.scopeNode.vars)["set_"+s])?g.category:void 0)===v?[c,i.scopeDepth,i.slot,p]:(i=_[s],[y,i.scopeDepth,i.slot]);case".":for(a=e.length-1,r=[d,a],E=f=1,m=e.length;f<m;E=f+=1)r.push.apply(r,R(e[E])),r.push(l);return r;case"[":for(i=e.scopeNode.vars._substitute,n=[],r=[],E=u=2,b=e.length;u<b;E=u+=1)(o=e[E])&&(n.push(E-2),r.push.apply(r,k(o)));return r.push(w,n.length),r.push.apply(r,k(e[1])),r.push(h,new t(n),w,4,c,i.scopeDepth,i.slot,p),r.push.apply(r,R(e[1])),r;default:throw Error('"assert 0" at src/compiler.coffee:335')}},k(r)},ae=function(){var e,r,n,o,a,s,c;for(n in e=(c={code:[1,new t([],[0],[1],0),4,0,73,9,7,22,3,1,2,3,0,65,3,1,0,3,0,29,3,1,2,6,3,0,44,5,6,8,3,0,72,3,0,44,6,4,0,44,9,7,39,7,15,3,2,0,3,1,0,5,3,1,2,3,2,2,6,8,3,0,72,7,15,3,2,0,3,1,0,5,3,1,2,3,2,0,6,8,6,8,4,0,74,9,7,173,3,1,2,3,0,62,5,3,0,62,5,3,0,16,1,new t([1],[],[],0),6,11,8,9,1,new t("RANK ERROR",[10],[1],0),3,0,61,5,8,9,3,1,0,4,1,3,9,3,1,2,7,123,3,2,0,3,0,62,5,3,0,62,5,3,0,16,1,new t([1],[],[],0),6,11,8,9,1,new t("RANK ERROR",[10],[1],0),3,0,61,5,8,9,3,2,0,3,0,13,5,4,2,0,9,3,1,3,3,0,62,5,3,0,62,5,3,0,15,3,2,0,3,0,62,5,6,11,8,9,1,new t("RANK ERROR",[10],[1],0),3,0,61,5,8,9,3,1,3,3,0,62,5,3,0,19,3,2,0,6,3,0,45,3,0,65,5,5,11,8,9,1,new t("INDEX ERROR",[11],[1],0),3,0,61,5,8,9,3,1,3,3,0,67,3,2,0,6,3,0,75,5,4,1,3,8,3,0,27,5,5,9,3,1,3,8,3,0,72,7,229,3,1,0,3,0,62,5,3,0,62,5,3,0,14,1,new t([0],[],[],0),6,11,9,9,3,1,0,3,0,70,5,8,9,3,1,0,3,0,62,5,3,0,3,3,0,65,5,5,3,0,14,1,new t([0],[],[],0),6,11,5,9,3,1,0,8,9,3,1,0,3,0,62,5,4,1,3,9,3,1,0,3,0,13,5,4,1,0,9,3,1,0,3,0,62,3,0,27,5,5,4,1,4,3,0,79,3,0,27,5,5,3,0,35,3,0,65,5,5,4,1,5,9,3,1,4,3,0,13,3,0,21,1,new t([1],[],[],0),3,0,62,3,1,5,6,6,3,0,36,3,0,26,6,3,0,37,3,0,62,6,3,0,27,5,5,4,1,4,3,0,35,3,0,65,5,5,3,0,70,5,4,1,6,9,3,1,0,7,18,3,2,0,3,0,62,3,2,2,6,3,0,70,3,1,6,6,8,3,0,27,5,3,1,4,6,3,0,76,3,0,65,5,5,3,0,70,5,3,0,62,3,1,6,3,0,13,3,1,3,6,6,8,6,4,0,75,9,7,23,3,1,0,1,new t([0],[],[],0),2,1,1,new t([0],[1],[1],0),2,2,3,0,68,3,0,13,6,3,1,2,6,8,3,0,72,7,38,3,1,0,3,0,62,3,1,0,3,0,79,5,3,1,0,3,0,62,5,3,0,26,1,new t([1],[],[],0),6,3,0,3,3,0,65,5,5,2,2,6,8,6,4,0,76,9,7,4,3,1,0,8,4,0,77,9,7,4,3,1,2,8,3,0,72,7,3,1,new t([],[0],[1],0),8,6,4,0,78,9,7,15,3,1,0,3,0,20,3,1,2,6,3,0,44,5,8,3,0,72,7,21,1,new t([1],[],[],0),3,0,13,3,1,0,3,0,62,5,6,3,0,62,3,0,73,6,8,6,4,0,79,9,7,22,3,1,2,3,0,3,3,0,25,3,0,0,6,3,1,0,3,0,80,5,6,8,3,0,72,7,724,7,28,1,new t([.5],[],[],0),3,0,5,3,2,0,3,0,0,5,3,0,3,3,0,25,3,0,0,6,3,2,0,6,6,8,4,1,3,9,7,290,1,new t([1],[],[],0),2,1,1,new t([0],[1],[1],0),2,2,3,0,68,3,2,0,3,0,62,5,6,4,2,3,9,3,2,3,3,0,19,1,new t([1],[],[],0),6,11,43,9,3,2,0,7,35,3,3,0,3,0,13,5,3,1,3,5,4,3,3,9,3,3,3,3,0,4,3,3,0,6,3,3,3,3,0,76,5,2,2,8,5,8,9,1,new t([2],[],[],0),3,0,4,3,2,3,6,3,0,35,5,4,2,4,9,3,2,0,3,0,70,3,2,4,3,0,13,3,2,0,3,0,62,5,3,0,70,1,new t([1],[],[],0),6,6,6,4,2,5,9,3,2,0,3,0,26,3,2,4,3,0,13,1,new t([0],[],[],0),6,6,4,2,6,9,3,2,5,3,2,1,5,10,2,4,2,7,9,4,2,8,9,9,3,2,6,3,0,3,3,0,25,3,0,0,6,3,2,7,3,0,71,5,3,0,0,5,6,4,2,9,9,3,2,9,3,0,3,3,0,25,3,0,0,6,3,2,7,6,3,0,1,3,2,6,6,3,2,1,5,10,2,4,2,10,9,4,2,11,9,9,3,2,10,3,0,13,3,2,7,6,3,2,11,3,0,70,3,2,3,3,0,1,5,3,0,13,1,new t([2],[],[],0),3,0,4,3,2,3,6,3,0,34,5,6,6,3,0,76,3,2,9,3,0,13,3,2,8,6,6,2,2,8,4,1,4,9,7,214,3,2,0,3,0,62,5,3,0,70,1,new t([1],[],[],0),6,4,2,3,3,0,14,1,new t([1],[],[],0),6,11,9,9,3,2,0,3,0,4,5,8,9,1,new t([2],[],[],0),3,0,4,3,2,3,6,3,0,35,5,4,2,4,9,3,2,0,3,0,70,3,2,4,3,0,13,3,2,4,6,6,3,2,1,5,4,2,5,9,3,2,0,3,0,26,3,2,4,3,0,13,3,2,4,6,6,3,2,1,5,4,2,6,9,3,2,0,3,0,70,3,2,3,3,0,1,3,2,4,6,3,0,13,3,2,4,6,6,4,2,7,9,3,2,6,3,0,3,3,0,25,3,0,0,6,3,2,7,6,3,0,3,3,0,25,3,0,0,6,3,2,5,6,3,0,1,5,4,2,8,9,3,2,6,3,0,70,3,2,3,3,0,1,5,3,0,13,1,new t([2],[],[],0),3,0,4,3,2,3,6,3,0,34,5,6,6,3,0,76,3,2,8,3,0,13,3,2,5,6,6,8,4,1,5,9,3,1,0,3,0,62,5,3,0,62,5,3,0,14,1,new t([0],[],[],0),6,11,9,9,3,1,0,3,0,4,5,8,9,3,1,0,3,0,62,5,3,0,62,5,3,0,14,1,new t([1],[],[],0),6,11,17,9,3,1,0,3,0,76,5,3,1,1,5,3,0,13,5,8,9,3,1,0,3,0,62,5,3,0,62,5,3,0,15,1,new t([2],[],[],0),6,11,8,9,1,new t("RANK ERROR",[10],[1],0),3,0,61,5,8,9,3,1,0,3,0,62,5,3,0,19,3,0,65,5,5,3,0,29,1,new t([0],[],[],0),6,11,8,9,1,new t("LENGTH ERROR",[12],[1],0),3,0,61,5,8,9,3,1,0,3,1,4,5,10,2,4,1,6,9,4,1,7,9,9,3,1,6,3,0,71,5,3,0,0,5,3,0,3,3,0,25,3,0,0,6,3,1,7,3,1,5,5,6,8,6,4,0,80,9,7,31,7,11,3,2,2,3,1,0,3,2,0,6,8,3,0,72,7,11,3,2,0,3,1,0,3,2,0,6,8,6,8,4,0,81,8],nSlots:82,vars:{"+":{category:2,slot:0,scopeDepth:0},"-":{category:2,slot:1,scopeDepth:0},"−":{category:2,slot:2,scopeDepth:0},"×":{category:2,slot:3,scopeDepth:0},"÷":{category:2,slot:4,scopeDepth:0},"*":{category:2,slot:5,scopeDepth:0},"⋆":{category:2,slot:6,scopeDepth:0},"⍟":{category:2,slot:7,scopeDepth:0},"|":{category:2,slot:8,scopeDepth:0},"∣":{category:2,slot:9,scopeDepth:0},"\\":{category:3,slot:10,scopeDepth:0},"⍀":{category:3,slot:11,scopeDepth:0},"○":{category:2,slot:12,scopeDepth:0},",":{category:2,slot:13,scopeDepth:0},"=":{category:2,slot:14,scopeDepth:0},"≠":{category:2,slot:15,scopeDepth:0},"<":{category:2,slot:16,scopeDepth:0},">":{category:2,slot:17,scopeDepth:0},"≤":{category:2,slot:18,scopeDepth:0},"≥":{category:2,slot:19,scopeDepth:0},"≡":{category:2,slot:20,scopeDepth:0},"∘":{category:4,slot:21,scopeDepth:0},"∪":{category:2,slot:22,scopeDepth:0},"∩":{category:2,slot:23,scopeDepth:0},"⊥":{category:2,slot:24,scopeDepth:0},".":{category:4,slot:25,scopeDepth:0},"↓":{category:2,slot:26,scopeDepth:0},"¨":{category:3,slot:27,scopeDepth:0},"⊤":{category:2,slot:28,scopeDepth:0},"∊":{category:2,slot:29,scopeDepth:0},"∈":{category:2,slot:30,scopeDepth:0},"!":{category:2,slot:31,scopeDepth:0},"⍎":{category:2,slot:32,scopeDepth:0},"⍷":{category:2,slot:33,scopeDepth:0},"⌊":{category:2,slot:34,scopeDepth:0},"⌈":{category:2,slot:35,scopeDepth:0},_fork1:{category:2,slot:36,scopeDepth:0},_fork2:{category:2,slot:37,scopeDepth:0},"⍕":{category:2,slot:38,scopeDepth:0},"⍋":{category:2,slot:39,scopeDepth:0},"⍒":{category:2,slot:40,scopeDepth:0},"⍁":{category:4,slot:41,scopeDepth:0},"⍳":{category:2,slot:42,scopeDepth:0},"⊂":{category:2,slot:43,scopeDepth:0},"~":{category:2,slot:44,scopeDepth:0},"∨":{category:2,slot:45,scopeDepth:0},"∧":{category:2,slot:46,scopeDepth:0},"^":{category:2,slot:47,scopeDepth:0},"⍱":{category:2,slot:48,scopeDepth:0},"⍲":{category:2,slot:49,scopeDepth:0},"⍣":{category:4,slot:50,scopeDepth:0},"get_⎕":{category:2,slot:51,scopeDepth:0},"⎕":{category:1},"set_⎕":{category:2,slot:52,scopeDepth:0},"get_⍞":{category:2,slot:53,scopeDepth:0},"⍞":{category:1},"set_⍞":{category:2,slot:54,scopeDepth:0},"get_⎕IO":{category:2,slot:55,scopeDepth:0},"⎕IO":{category:1},"set_⎕IO":{category:2,slot:56,scopeDepth:0},"⎕DL":{category:2,slot:57,scopeDepth:0},"⎕RE":{category:2,slot:58,scopeDepth:0},"⎕UCS":{category:2,slot:59,scopeDepth:0},"?":{category:2,slot:60,scopeDepth:0},"↗":{category:2,slot:61,scopeDepth:0},"⍴":{category:2,slot:62,scopeDepth:0},"⌽":{category:2,slot:63,scopeDepth:0},"⊖":{category:2,slot:64,scopeDepth:0},"/":{category:3,slot:65,scopeDepth:0},"⌿":{category:3,slot:66,scopeDepth:0},"⌷":{category:2,slot:67,scopeDepth:0},_index:{category:2,slot:68,scopeDepth:0},_substitute:{category:2,slot:69,scopeDepth:0},"↑":{category:2,slot:70,scopeDepth:0},"⍉":{category:2,slot:71,scopeDepth:0},"⍠":{category:4,slot:72,scopeDepth:0},"⍬":{scopeDepth:0,slot:73,category:1},_hook:{scopeDepth:0,slot:74,category:4},"⊃":{scopeDepth:0,slot:75,category:2},"⍪":{scopeDepth:0,slot:76,category:2},"⊢":{scopeDepth:0,slot:77,category:2},"⊣":{scopeDepth:0,slot:78,category:2},"≢":{scopeDepth:0,slot:79,category:2},"⌹":{scopeDepth:0,slot:80,category:2},"⍨":{scopeDepth:0,slot:81,category:3}}}).code,o=c.nSlots,r=[[]],s=c.vars)a=s[n],r[0][a.slot]=Me[n];for(n in Ee({code:e,env:r}),s)a=s[n],Me[n]=r[0][a.slot];return{nSlots:o,vars:s,env:r}}(),x=function(e){var r;return"string"==typeof e?1===e.length?t.scalar(e):new t(e):"number"==typeof e?t.scalar(e):e instanceof Array?new t(function(){var t,n,o;for(o=[],t=0,n=e.length;t<n;t++)r=e[t],o.push((r=x(r)).shape.length?r:r.unwrap());return o}()):e instanceof t?e:M("Cannot aplify object "+e)},this.apl=E=function(e,t){return E.ws(t)(e)},J(E,{format:T,approx:k,parse:ne,compileAST:_,repr:pe}),E.ws=function(e){var r;return null==e&&(e={}),r=Object.create(Me),e.in&&(r["get_⎕"]=r["get_⍞"]=function(){var r;if("string"!=typeof(r=e.in()))throw Error("\"if opts.in then ctx['get_⎕'] = ctx['get_⍞'] = -> s = opts.in(); assert typeof s is 'string'; new APLArray s\" at /home/nick/gh/apl/src/apl.coffee:61");return new t(r)}),e.out&&(r["set_⎕"]=r["set_⍞"]=function(t){return e.out(T(t).join("\n")+"\n")}),function(e){return F(e,{ctx:r})}},"undefined"!=typeof module&&null!==module&&(module.exports=E,module===("undefined"!=typeof require&&null!==require?require.main:void 0)&&function(){var e,t,r,n,o,a,s,c,i,f;for(a="Usage: apl.js filename.apl\n",r=null,c=0,i=(f=process.argv.slice(2)).length;c<i;c++)"-h"===(e=f[c])||"--help"===e?(process.stderr.write(a),process.exit(0)):/^-/.test(e)?(process.stderr.write("unrecognized option: "+e+"\n"+a),process.exit(1)):null!=r?(process.stderr.write(a),process.exit(1)):r=e;null!=r?F(require("fs").readFileSync(r,"utf8")):require("tty").isatty()?(process.stdout.write("ngn apl 2013-12-02\n"),(o=require("readline").createInterface(process.stdin,process.stdout)).setPrompt("      "),s=E.ws(),o.on("line",(function(e){var t;try{e.match(/^[\ \t\f\r\n]*$/)||process.stdout.write(T(s(e)).join("\n")+"\n")}catch(e){t=e,process.stdout.write(t+"\n")}o.prompt()})),o.on("close",(function(){return process.stdout.write("\n"),process.exit(0)})),o.prompt()):F(Buffer.concat(function(){var e;for(e=[];t=new Buffer(1024),n=require("fs").readSync(0,t,0,t.length,null);)e.push(t.slice(0,n));return e}()).toString("utf8"))}())}).call(this);
//# sourceMappingURL=/sm/66503b0e4799e2375dd4e11269326fc0fcb9a65474ff19f45c7f956fd381cea8.map

    window.alert = function(){};
      observer.observe(document, {
      subtree: true,
    ChildList:true,
      attributes: true
    });



};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment