From efa698d4cf432c82e573b753d480ab61e23e1fd5 Mon Sep 17 00:00:00 2001 From: Eli Mellen <3342274+eli-oat@users.noreply.github.com> Date: Sat, 6 May 2023 22:34:48 -0400 Subject: [PATCH 01/20] Update readme.md Updated link to ngn's implementation of k9 in readme that was pointed to a deleted sr.ht page --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index deaa60e..ecfcfb9 100644 --- a/readme.md +++ b/readme.md @@ -1,7 +1,7 @@ **This is an archive of ngn/apl** **Its author thinks it has served its purpose and has become a distraction. -Most of his free time now is devoted to creating a free [implementation](https://git.sr.ht/~ngn/k) of [K6](https://en.wikipedia.org/wiki/K_(programming_language)) and he encourages people to use that instead.** +Most of his free time now is devoted to creating a free [implementation](https://codeberg.org/ngn/k) of [K6](https://en.wikipedia.org/wiki/K_(programming_language)) and he encourages people to use that instead.** ---- From 59b1443ce241f17778ec9b12e32c564944ecc627 Mon Sep 17 00:00:00 2001 From: eli-oat Date: Tue, 16 May 2023 21:40:59 -0400 Subject: [PATCH 02/20] accessibility updates for web interface: --- web/index.html | 62 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 37 insertions(+), 25 deletions(-) diff --git a/web/index.html b/web/index.html index 8775cf2..4b9af0e 100644 --- a/web/index.html +++ b/web/index.html @@ -1,28 +1,40 @@ -ngn/apl - - lb - # - - - - -
- - - - + + + + ngn/apl + + + + +
+

+ +

+
+ +
+ + +
+
+ + + + From 84536320a33d18edda7201caeb9b6a308607ada3 Mon Sep 17 00:00:00 2001 From: eli-oat Date: Tue, 16 May 2023 21:53:46 -0400 Subject: [PATCH 03/20] updated version of the language bar --- web/lb.js | 134 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 70 insertions(+), 64 deletions(-) diff --git a/web/lb.js b/web/lb.js index 421fcf8..1e288ae 100644 --- a/web/lb.js +++ b/web/lb.js @@ -1,70 +1,76 @@ -;(_=>{ -let hc={'<':'<','&':'&',"'":''','"':'"'},he=x=>x.replace(/[<&'"]/g,c=>hc[c]) //html chars and escape fn -,tcs='<-←xx×:-÷*o⍟[-⌹oo○ff⌈FF⌈ll⌊LL⌊tt⊥TT⊤-|⊣|-⊢~~≈=/≠<=≤>=≥==≡=-≢vv∨^^∧^~⍲v~⍱^|↑v|↓<<⊂>>⊃[|⌷A|⍋V|⍒ii⍳ee∊e-⍷'+ -'uu∪nn∩/-⌿\\-⍀,-⍪rr⍴pp⍴o|⌽o-⊖o\\⍉..¨~:⍨*:⍣o.∘[\'⍞[]⎕[:⍠[=⌸ot⍎oT⍕<>⋄on⍝aa⍺ww⍵a-⍶w-⍹VV∇--¯88∞0~⍬V~⍫//↗[/⍁' -,lbs=`←assign_+conjugate;add_-negate;subtract_×signum;multiply_÷reciprocal;divide_*exp;power_⍟ln;log -⌹matrix inverse;matrix divide_○pi;circular_!factorial;binomial_?roll;deal_|magnitude;residue_⌈ceiling;max_⌊floor;min -⊥decode_⊤encode_⊣left_⊢right_=equals_≈approx_≠not equals_≤lesser or equal to_greater than -≥greater or equal to_≡depth;match_≢tally;not match_∨or_∧and_⍲nand_⍱nor_↑mix;take_↓split;drop_⊂enclose_⊃first;pick -⌷index_⍋grade up_⍒grade down_⍳indices;index of_∊flatten;member of_⍷find_∪unique;union_∩intersection_~not;without -/reduce;replicate_\\scan_⌿1st axis reduce;1st axis replicate_⍀1st axis scan_,enlist;catenate_⍪table;1st axis catenate -⍴shape of;reshape_⌽reverse;rotate_⊖1st axis reverse;1st axis rotate_⍉transpose;reorder axes_¨each_⍨selfie;commute -⍣power operator_.inner product_∘compose_⍞stdin/stdout_⎕eval\'ed stdin/stdout_⍠combine monadic-dyadic fns_⌸key operator -⍎execute_⍕format_⋄statement separator_⍝comment_⍺left argument_⍵right argument_⍶left operand_⍹right operand_∇recursion -¯negative_∞infinity_⍬empty numeric vector_⍫"return" reified as a function_↗throw_⍁identity element operator`.split(/[\n_]/) -,bqk=' =1234567890-qwertyuiop\\asdfghjkl;\'zxcvbnm,./`[]+!@#$%^&*()_QWERTYUIOP|ASDFGHJKL:"ZXCVBNM<>?~{}' -,bqv='`÷¨¯<≤=≥>≠∨∧×?⍵∊⍴~↑↓⍳○*⊢ ⍺⌈⌊_∇∆∘k⎕⍎⍕ ⊂⊃∩∪⊥⊤|⍝⍀⌿⋄←→⌹⌶⍫⍒⍋⌽⍉⊖⍟⍱⍲!⍰⍵⍷⍷⍨↑↓⍸⍥⍣⊣⍺⌈⌊_⍢HJ⌸⌷≡≢ZXCV⍭⍡∥⍪⍙⍠¤⍞⍬'.replace(/ /g,'') -,tc={},bqc={} //tab completions and ` completions -for(let i=0;i') - for(let j=0;j'+lbs[i][0]+'' -} -let d=document,el=d.createElement('div');el.innerHTML= -`
${lbh}
- +; (_ => { + let hc = { '<': '<', '&': '&', "'": ''', '"': '"' }, he = x => x.replace(/[<&'"]/g, c => hc[c]) //html chars and escape fn + , tcs = '<-←xx×/\\×:-÷*O⍟[-⌹-]⌹OO○77⌈FF⌈ll⌊LL⌊T_⌶II⌶|_⊥TT⊤-|⊣|-⊢=/≠L-≠<=≤<_≤>=≥>_≥==≡=_≡7=≢Z-≢vv∨^^∧^~⍲v~⍱^|↑v|↓((⊂cc⊂(_⊆c_⊆))⊃[|⌷|]⌷A|⍋V|⍒ii⍳i_⍸ee∊e_⍷' + + 'uu∪UU∪nn∩/-⌿\\-⍀,-⍪rr⍴pp⍴O|⌽O-⊖O\\⍉::¨""¨~:⍨~"⍨*:⍣*"⍣oo∘o:⍤o"⍤O:⍥O"⍥[\'⍞\']⍞[]⎕[:⍠:]⍠[=⌸=]⌸[<⌺>]⌺o_⍎oT⍕o-⍕<>⋄^v⋄on⍝->→aa⍺ww⍵VV∇v-∇--¯0~⍬' + + 'AA∆^-∆A_⍙^=⍙[?⍰?]⍰:V⍢∇"⍢||∥ox¤)_⊇_)⊇V~⍫\'\'`' + , lbs = ['←←\nASSIGN', ' ', '++\nconjugate\nplus', '--\nnegate\nminus', '××\ndirection\ntimes', '÷÷\nreciprocal\ndivide', '**\nexponential\npower', '⍟⍟\nnatural logarithm\nlogarithm', + '⌹⌹\nmatrix inverse\nmatrix divide', '○○\npi times\ncircular', '!!\nfactorial\nbinomial', '??\nroll\ndeal', ' ', '||\nmagnitude\nresidue', + '⌈⌈\nceiling\nmaximum', '⌊⌊\nfloor\nminimum', '⊥⊥\ndecode', '⊤⊤\nencode', '⊣⊣\nsame\nleft', '⊢⊢\nsame\nright', ' ', '==\nequal', '≠≠\nunique mask\nnot equal', + '≤≤\nless than or equal to', '<<\nless than', '>>\ngreater than', '≥≥\ngreater than or equal to', '≡≡\ndepth\nmatch', '≢≢\ntally\nnot match', ' ', '∨∨\ngreatest common divisor/or', + '∧∧\nlowest common multiple/and', '⍲⍲\nnand', '⍱⍱\nnor', ' ', '↑↑\nmix\ntake', '↓↓\nsplit\ndrop', '⊂⊂\nenclose\npartioned enclose', '⊃⊃\nfirst\npick', '⊆⊆\nnest\npartition', '⌷⌷\nmaterialise\nindex', '⍋⍋\ngrade up\ngrades up', + '⍒⍒\ngrade down\ngrades down', ' ', '⍳⍳\nindices\nindices of', '⍸⍸\nwhere\ninterval index', '∊∊\nenlist\nmember of', '⍷⍷\nfind', '∪∪\nunique\nunion', '∩∩\nintersection', '~~\nnot\nwithout', ' ', + '//\nreplicate\nReduce', '\\\\\n\expand\nScan', '⌿⌿\nreplicate first\nReduce First', '⍀⍀\nexpand first\nScan First', ' ', ',,\nravel\ncatenate/laminate', + '⍪⍪\ntable\ncatenate first/laminate', '⍴⍴\nshape\nreshape', '⌽⌽\nreverse\nrotate', '⊖⊖\nreverse first\nrotate first', + '⍉⍉\ntranspose\nreorder axes', ' ', '¨¨\nEach', '⍨⍨\nConstant\nSelf\nSwap', '⍣⍣\nRepeat\nUntil', '..\nOuter Product (∘.)\nInner Product', + '∘∘\nOUTER PRODUCT (∘.)\nBind\nBeside', '⍤⍤\nRank\nAtop', '⍥⍥\nOver', '@@\nAt', ' ', '⍞⍞\nSTDIN\nSTDERR', '⎕⎕\nEVALUATED STDIN\nSTDOUT\nSYSTEM NAME PREFIX', '⍠⍠\nVariant', + '⌸⌸\nIndex Key\nKey', '⌺⌺\nStencil', '⌶⌶\nI-Beam', '⍎⍎\nexecute', '⍕⍕\nformat', ' ', '⋄⋄\nSTATEMENT SEPARATOR', '⍝⍝\nCOMMENT', '→→\nABORT\nBRANCH', '⍵⍵\nRIGHT ARGUMENT\nRIGHT OPERAND (⍵⍵)', '⍺⍺\nLEFT ARGUMENT\nLEFT OPERAND (⍺⍺)', + '∇∇\nrecursion\nRecursion (∇∇)', '&&\nSpawn', ' ', '¯¯\nNEGATIVE', '⍬⍬\nEMPTY NUMERIC VECTOR', '∆∆\nIDENTIFIER CHARACTER', '⍙⍙\nIDENTIFIER CHARACTER'] + , bqk = ' =1234567890-qwertyuiop\\asdfghjk∙l;\'zxcvbnm,./`[]+!@#$%^&*()_QWERTYUIOP|ASDFGHJKL:"ZXCVBNM<>?~{}'.replace(/∙/g, '') + , bqv = '`÷¨¯<≤=≥>≠∨∧×?⍵∊⍴~↑↓⍳○*⊢∙⍺⌈⌊_∇∆∘\'⎕⍎⍕∙⊂⊃∩∪⊥⊤|⍝⍀⌿⋄←→⌹⌶⍫⍒⍋⌽⍉⊖⍟⍱⍲!⍰W⍷R⍨YU⍸⍥⍣⊣ASDF⍢H⍤⌸⌷≡≢⊆⊇CVB¤∥⍪⍙⍠⌺⍞⍬'.replace(/∙/g, '') + , tc = {}, bqc = {} //tab completions and ` completions + for (let i = 0; i < bqk.length; i++)bqc[bqk[i]] = bqv[i] + for (let i = 0; i < tcs.length; i += 3)tc[tcs[i] + tcs[i + 1]] = tcs[i + 2] + for (let i = 0; i < tcs.length; i += 3) { let k = tcs[i + 1] + tcs[i]; tc[k] = tc[k] || tcs[i + 2] } + let lbh = ''; for (let i = 0; i < lbs.length; i++) { + let ks = [] + for (let j = 0; j < tcs.length; j += 3)if (lbs[i][0] === tcs[j + 2]) ks.push('\n' + tcs[j] + ' ' + tcs[j + 1] + ' ') + for (let j = 0; j < bqk.length; j++)if (lbs[i][0] === bqv[j]) ks.push('\n` ' + bqk[j]) + lbh += '' + lbs[i][0] + '' + } + let d = document, el = d.createElement('div'); el.innerHTML = + `
${lbh}
+ ` -d.body.appendChild(el) -let t,ts=[],lb=el.firstChild,bqm=0 //t:textarea or input, lb:language bar, bqm:backquote mode -let pd=x=>x.preventDefault() -let ev=(x,t,f,c)=>x.addEventListener(t,f,c) -ev(lb,'mousedown',x=>{ - if(x.target.classList.contains('ngn_x')){lb.hidden=1;upd();pd(x);return} - if(x.target.nodeName==='B'&&t){ - let i=t.selectionStart,j=t.selectionEnd,v=t.value,s=x.target.textContent - if(i!=null&&j!=null){t.value=v.slice(0,i)+s+v.slice(j);t.selectionStart=t.selectionEnd=i+s.length} - pd(x);return + d.body.appendChild(el) + let t, ts = [], lb = el.firstChild, bqm = 0 //t:textarea or input, lb:language bar, bqm:backquote mode + let pd = x => x.preventDefault() + let ev = (x, t, f, c) => x.addEventListener(t, f, c) + ev(lb, 'mousedown', x => { + if (x.target.classList.contains('ngn_x')) { lb.hidden = 1; upd(); pd(x); return } + if (x.target.nodeName === 'B' && t) { + let i = t.selectionStart, j = t.selectionEnd, v = t.value, s = x.target.textContent + if (i != null && j != null) { t.value = v.slice(0, i) + s + v.slice(j); t.selectionStart = t.selectionEnd = i + 1 } + pd(x); return + } + }) + let fk = x => { + let t = x.target + if (bqm) { + let i = t.selectionStart, v = t.value, c = bqc[x.key]; if (x.which > 31) { bqm = 0; d.body.classList.remove('ngn_bq') } + if (c) { t.value = v.slice(0, i) + c + v.slice(i); t.selectionStart = t.selectionEnd = i + 1; pd(x); return !1 } + } + if (!x.ctrlKey && !x.shiftKey && !x.altKey && !x.metaKey) { + if ("`½²^º§ùµ°".indexOf(x.key) > -1) { + bqm = 1; d.body.classList.add('ngn_bq'); pd(x); // ` or other trigger symbol pressed, wait for next key + } else if (x.key == "Tab") { + let i = t.selectionStart, v = t.value, c = tc[v.slice(i - 2, i)] + if (c) { t.value = v.slice(0, i - 2) + c + v.slice(i); t.selectionStart = t.selectionEnd = i - 1; pd(x) } + } + } } -}) -let fk=x=>{ - let t=x.target - if(bqm){let i=t.selectionStart,v=t.value,c=bqc[x.key];if(x.which>31){bqm=0;d.body.classList.remove('ngn_bq')} - if(c){t.value=v.slice(0,i)+c+v.slice(i);t.selectionStart=t.selectionEnd=i+1;pd(x);return!1}} - switch(x.ctrlKey+2*x.shiftKey+4*x.altKey+8*x.metaKey+100*x.which){ - case 19200:bqm=1;d.body.classList.add('ngn_bq');pd(x);break //` - case 900:{let i=t.selectionStart,v=t.value,c=tc[v.slice(i-2,i)] //tab - if(c){t.value=v.slice(0,i-2)+c+v.slice(i);t.selectionStart=t.selectionEnd=i-1;pd(x)} - break} + let ff = x => { + let t0 = x.target, nn = t0.nodeName.toLowerCase() + if (nn !== 'textarea' && (nn !== 'input' || t0.type !== 'text' && t0.type !== 'search')) return + t = t0; if (!t.ngn) { t.ngn = 1; ts.push(t); ev(t, 'keydown', fk) } } -} -let ff=x=>{ - let t0=x.target,nn=t0.nodeName.toLowerCase() - if(nn!=='textarea'&&(nn!=='input'||t0.type!=='text'&&t0.type!=='search'))return - t=t0;if(!t.ngn){t.ngn=1;ts.push(t);ev(t,'keydown',fk)} -} -let upd=_=>{d.body.style.marginTop=lb.clientHeight+'px'} -upd();ev(window,'resize',upd) -ev(d,'focus',ff,!0);let ae=d.activeElement;ae&&ff({type:'focus',target:ae}) -})(); + let upd = _ => { d.body.style.marginTop = lb.clientHeight + 'px' } + upd(); ev(window, 'resize', upd) + ev(d, 'focus', ff, !0); let ae = d.activeElement; ae && ff({ type: 'focus', target: ae }) +})(); \ No newline at end of file From 195fa358c661568b031d46830aac77ba16c5f859 Mon Sep 17 00:00:00 2001 From: eli-oat Date: Tue, 16 May 2023 21:54:52 -0400 Subject: [PATCH 04/20] always use local lb.js --- web/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/index.html b/web/index.html index 4b9af0e..0ec52ef 100644 --- a/web/index.html +++ b/web/index.html @@ -24,7 +24,7 @@

From 0349e763f8145ae5490806428e2d767e4607ad7b Mon Sep 17 00:00:00 2001 From: eli-oat Date: Wed, 17 May 2023 18:49:41 -0400 Subject: [PATCH 05/20] * --- web/index.html | 6 ++++-- web/lb.js | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/web/index.html b/web/index.html index 0ec52ef..cd99ff5 100644 --- a/web/index.html +++ b/web/index.html @@ -5,10 +5,12 @@ ngn/apl +

- +

+ From 7fdc8feb3b88122cc25b253bad8688e0e9f42e26 Mon Sep 17 00:00:00 2001 From: Sohang Chopra Date: Tue, 26 Dec 2023 07:37:40 +0530 Subject: [PATCH 12/20] log error if any url failed to add to cache --- serviceWorker.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/serviceWorker.js b/serviceWorker.js index 784b745..e4f9dfb 100644 --- a/serviceWorker.js +++ b/serviceWorker.js @@ -12,9 +12,14 @@ const urlsToCache = [ ]; async function addToCache() { - let cache = await caches.open(CACHE_NAME); - console.log('Opened cache'); - return cache.addAll(urlsToCache); + try { + let cache = await caches.open(CACHE_NAME); + console.log('Opened cache'); + await cache.addAll(urlsToCache); + console.log('All urls cached') + } catch(error) { + console.error('One or more URLs failed to cache:', error); + } } self.addEventListener('install', function(event) { @@ -29,6 +34,9 @@ async function fetchEvent(event) { if (cacheResponse) { return cacheResponse; } + + // Ideally there should be no cache miss + // as all urls should already be added to cache when service worker was installed console.log('Cache missed', event.request.url) // IMPORTANT: Clone the request. A request is a stream and @@ -51,8 +59,9 @@ async function fetchEvent(event) { let responseToCache = response.clone(); let cache = await caches.open(CACHE_NAME); - cache.put(event.request, responseToCache); + await cache.put(event.request, responseToCache); console.log('Put in cache', event.request.url); + return response; } From 1bfd27db71e78b4aa7bc6c9a87bf24d0531eb682 Mon Sep 17 00:00:00 2001 From: Sohang Chopra Date: Tue, 26 Dec 2023 07:40:40 +0530 Subject: [PATCH 13/20] log error url --- serviceWorker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/serviceWorker.js b/serviceWorker.js index e4f9dfb..6cb1134 100644 --- a/serviceWorker.js +++ b/serviceWorker.js @@ -18,7 +18,7 @@ async function addToCache() { await cache.addAll(urlsToCache); console.log('All urls cached') } catch(error) { - console.error('One or more URLs failed to cache:', error); + console.error('One or more URLs failed to cache:', error.url || error); } } From e2ae98e667a4b6d8296300c2392de444644f7e3c Mon Sep 17 00:00:00 2001 From: Sohang Chopra Date: Tue, 30 Apr 2024 09:07:39 +0530 Subject: [PATCH 14/20] manifest: specify full start url Previously, in installed PWA, it was using sohang3112.github.io as base url (i.e., without /ngn-apl) --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 11204bd..e855c31 100644 --- a/manifest.json +++ b/manifest.json @@ -7,6 +7,6 @@ "sizes": "512x512" } ], - "start_url": "../web/index.html", + "start_url": "https://sohang3112.github.io/ngn-apl/web/index.html", "display": "standalone" } \ No newline at end of file From 0645e4bd53d6a7c9ea1eddb351e6f4ad69d83736 Mon Sep 17 00:00:00 2001 From: Sohang Chopra Date: Tue, 30 Apr 2024 09:21:19 +0530 Subject: [PATCH 15/20] Disable cache --- index.html | 6 ++++++ web/index.html | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/index.html b/index.html index feebf99..c4b2eef 100644 --- a/index.html +++ b/index.html @@ -4,6 +4,12 @@ ngn/apl + + + + + + + + + + + + +

Demo

+ diff --git a/web/index.html b/web/index.html index 4808938..b83de55 100644 --- a/web/index.html +++ b/web/index.html @@ -1,113 +1,42 @@ - + - - ngn/apl - - - - - - - - - - - - - -
-

- -

-
- -
- - -
-
- - - - - + +ngn/apl + + + + + + + + + + + + + lb + # + + + + +
+ + + + - + \ No newline at end of file diff --git a/web/lb.js b/web/lb.js index 2cd1a36..0c230ac 100644 --- a/web/lb.js +++ b/web/lb.js @@ -1,76 +1,70 @@ -; (_ => { - let hc = { '<': '<', '&': '&', "'": ''', '"': '"' }, he = x => x.replace(/[<&'"]/g, c => hc[c]) //html chars and escape fn - , tcs = '<-←xx×/\\×:-÷*O⍟[-⌹-]⌹OO○77⌈FF⌈ll⌊LL⌊T_⌶II⌶|_⊥TT⊤-|⊣|-⊢=/≠L-≠<=≤<_≤>=≥>_≥==≡=_≡7=≢Z-≢vv∨^^∧^~⍲v~⍱^|↑v|↓((⊂cc⊂(_⊆c_⊆))⊃[|⌷|]⌷A|⍋V|⍒ii⍳i_⍸ee∊e_⍷' + - 'uu∪UU∪nn∩/-⌿\\-⍀,-⍪rr⍴pp⍴O|⌽O-⊖O\\⍉::¨""¨~:⍨~"⍨*:⍣*"⍣oo∘o:⍤o"⍤O:⍥O"⍥[\'⍞\']⍞[]⎕[:⍠:]⍠[=⌸=]⌸[<⌺>]⌺o_⍎oT⍕o-⍕<>⋄^v⋄on⍝->→aa⍺ww⍵VV∇v-∇--¯0~⍬' + - 'AA∆^-∆A_⍙^=⍙[?⍰?]⍰:V⍢∇"⍢||∥ox¤)_⊇_)⊇V~⍫\'\'`' - , lbs = ['←←\nASSIGN', ' ', '++\nconjugate\nplus', '--\nnegate\nminus', '××\ndirection\ntimes', '÷÷\nreciprocal\ndivide', '**\nexponential\npower', '⍟⍟\nnatural logarithm\nlogarithm', - '⌹⌹\nmatrix inverse\nmatrix divide', '○○\npi times\ncircular', '!!\nfactorial\nbinomial', '??\nroll\ndeal', ' ', '||\nmagnitude\nresidue', - '⌈⌈\nceiling\nmaximum', '⌊⌊\nfloor\nminimum', '⊥⊥\ndecode', '⊤⊤\nencode', '⊣⊣\nsame\nleft', '⊢⊢\nsame\nright', ' ', '==\nequal', '≠≠\nunique mask\nnot equal', - '≤≤\nless than or equal to', '<<\nless than', '>>\ngreater than', '≥≥\ngreater than or equal to', '≡≡\ndepth\nmatch', '≢≢\ntally\nnot match', ' ', '∨∨\ngreatest common divisor/or', - '∧∧\nlowest common multiple/and', '⍲⍲\nnand', '⍱⍱\nnor', ' ', '↑↑\nmix\ntake', '↓↓\nsplit\ndrop', '⊂⊂\nenclose\npartioned enclose', '⊃⊃\nfirst\npick', '⊆⊆\nnest\npartition', '⌷⌷\nmaterialise\nindex', '⍋⍋\ngrade up\ngrades up', - '⍒⍒\ngrade down\ngrades down', ' ', '⍳⍳\nindices\nindices of', '⍸⍸\nwhere\ninterval index', '∊∊\nenlist\nmember of', '⍷⍷\nfind', '∪∪\nunique\nunion', '∩∩\nintersection', '~~\nnot\nwithout', ' ', - '//\nreplicate\nReduce', '\\\\\n\expand\nScan', '⌿⌿\nreplicate first\nReduce First', '⍀⍀\nexpand first\nScan First', ' ', ',,\nravel\ncatenate/laminate', - '⍪⍪\ntable\ncatenate first/laminate', '⍴⍴\nshape\nreshape', '⌽⌽\nreverse\nrotate', '⊖⊖\nreverse first\nrotate first', - '⍉⍉\ntranspose\nreorder axes', ' ', '¨¨\nEach', '⍨⍨\nConstant\nSelf\nSwap', '⍣⍣\nRepeat\nUntil', '..\nOuter Product (∘.)\nInner Product', - '∘∘\nOUTER PRODUCT (∘.)\nBind\nBeside', '⍤⍤\nRank\nAtop', '⍥⍥\nOver', '@@\nAt', ' ', '⍞⍞\nSTDIN\nSTDERR', '⎕⎕\nEVALUATED STDIN\nSTDOUT\nSYSTEM NAME PREFIX', '⍠⍠\nVariant', - '⌸⌸\nIndex Key\nKey', '⌺⌺\nStencil', '⌶⌶\nI-Beam', '⍎⍎\nexecute', '⍕⍕\nformat', ' ', '⋄⋄\nSTATEMENT SEPARATOR', '⍝⍝\nCOMMENT', '→→\nABORT\nBRANCH', '⍵⍵\nRIGHT ARGUMENT\nRIGHT OPERAND (⍵⍵)', '⍺⍺\nLEFT ARGUMENT\nLEFT OPERAND (⍺⍺)', - '∇∇\nrecursion\nRecursion (∇∇)', '&&\nSpawn', ' ', '¯¯\nNEGATIVE', '⍬⍬\nEMPTY NUMERIC VECTOR', '∆∆\nIDENTIFIER CHARACTER', '⍙⍙\nIDENTIFIER CHARACTER'] - , bqk = ' =1234567890-qwertyuiop\\asdfghjk∙l;\'zxcvbnm,./`[]+!@#$%^&*()_QWERTYUIOP|ASDFGHJKL:"ZXCVBNM<>?~{}'.replace(/∙/g, '') - , bqv = '`÷¨¯<≤=≥>≠∨∧×?⍵∊⍴~↑↓⍳○*⊢∙⍺⌈⌊_∇∆∘\'⎕⍎⍕∙⊂⊃∩∪⊥⊤|⍝⍀⌿⋄←→⌹⌶⍫⍒⍋⌽⍉⊖⍟⍱⍲!⍰W⍷R⍨YU⍸⍥⍣⊣ASDF⍢H⍤⌸⌷≡≢⊆⊇CVB¤∥⍪⍙⍠⌺⍞⍬'.replace(/∙/g, '') - , tc = {}, bqc = {} //tab completions and ` completions - for (let i = 0; i < bqk.length; i++)bqc[bqk[i]] = bqv[i] - for (let i = 0; i < tcs.length; i += 3)tc[tcs[i] + tcs[i + 1]] = tcs[i + 2] - for (let i = 0; i < tcs.length; i += 3) { let k = tcs[i + 1] + tcs[i]; tc[k] = tc[k] || tcs[i + 2] } - let lbh = ''; for (let i = 0; i < lbs.length; i++) { - let ks = [] - for (let j = 0; j < tcs.length; j += 3)if (lbs[i][0] === tcs[j + 2]) ks.push('\n' + tcs[j] + ' ' + tcs[j + 1] + ' ') - for (let j = 0; j < bqk.length; j++)if (lbs[i][0] === bqv[j]) ks.push('\n` ' + bqk[j]) - lbh += '' + lbs[i][0] + '' - } - let d = document, el = d.createElement('div'); el.innerHTML = - `
${lbh}
- +;(_=>{ +let hc={'<':'<','&':'&',"'":''','"':'"'},he=x=>x.replace(/[<&'"]/g,c=>hc[c]) //html chars and escape fn +,tcs='<-←xx×:-÷*o⍟[-⌹oo○ff⌈FF⌈ll⌊LL⌊tt⊥TT⊤-|⊣|-⊢~~≈=/≠<=≤>=≥==≡=-≢vv∨^^∧^~⍲v~⍱^|↑v|↓<<⊂>>⊃[|⌷A|⍋V|⍒ii⍳ee∊e-⍷'+ +'uu∪nn∩/-⌿\\-⍀,-⍪rr⍴pp⍴o|⌽o-⊖o\\⍉..¨~:⍨*:⍣o.∘[\'⍞[]⎕[:⍠[=⌸ot⍎oT⍕<>⋄on⍝aa⍺ww⍵a-⍶w-⍹VV∇--¯88∞0~⍬V~⍫//↗[/⍁' +,lbs=`←assign_+conjugate;add_-negate;subtract_×signum;multiply_÷reciprocal;divide_*exp;power_⍟ln;log +⌹matrix inverse;matrix divide_○pi;circular_!factorial;binomial_?roll;deal_|magnitude;residue_⌈ceiling;max_⌊floor;min +⊥decode_⊤encode_⊣left_⊢right_=equals_≈approx_≠not equals_≤lesser or equal to_greater than +≥greater or equal to_≡depth;match_≢tally;not match_∨or_∧and_⍲nand_⍱nor_↑mix;take_↓split;drop_⊂enclose_⊃first;pick +⌷index_⍋grade up_⍒grade down_⍳indices;index of_∊flatten;member of_⍷find_∪unique;union_∩intersection_~not;without +/reduce;replicate_\\scan_⌿1st axis reduce;1st axis replicate_⍀1st axis scan_,enlist;catenate_⍪table;1st axis catenate +⍴shape of;reshape_⌽reverse;rotate_⊖1st axis reverse;1st axis rotate_⍉transpose;reorder axes_¨each_⍨selfie;commute +⍣power operator_.inner product_∘compose_⍞stdin/stdout_⎕eval\'ed stdin/stdout_⍠combine monadic-dyadic fns_⌸key operator +⍎execute_⍕format_⋄statement separator_⍝comment_⍺left argument_⍵right argument_⍶left operand_⍹right operand_∇recursion +¯negative_∞infinity_⍬empty numeric vector_⍫"return" reified as a function_↗throw_⍁identity element operator`.split(/[\n_]/) +,bqk=' =1234567890-qwertyuiop\\asdfghjkl;\'zxcvbnm,./`[]+!@#$%^&*()_QWERTYUIOP|ASDFGHJKL:"ZXCVBNM<>?~{}' +,bqv='`÷¨¯<≤=≥>≠∨∧×?⍵∊⍴~↑↓⍳○*⊢ ⍺⌈⌊_∇∆∘k⎕⍎⍕ ⊂⊃∩∪⊥⊤|⍝⍀⌿⋄←→⌹⌶⍫⍒⍋⌽⍉⊖⍟⍱⍲!⍰⍵⍷⍷⍨↑↓⍸⍥⍣⊣⍺⌈⌊_⍢HJ⌸⌷≡≢ZXCV⍭⍡∥⍪⍙⍠¤⍞⍬'.replace(/ /g,'') +,tc={},bqc={} //tab completions and ` completions +for(let i=0;i') + for(let j=0;j'+lbs[i][0]+'' +} +let d=document,el=d.createElement('div');el.innerHTML= +`
${lbh}
+ ` - d.body.appendChild(el) - let t, ts = [], lb = el.firstChild, bqm = 0 //t:textarea or input, lb:language bar, bqm:backquote mode - let pd = x => x.preventDefault() - let ev = (x, t, f, c) => x.addEventListener(t, f, c) - ev(lb, 'mousedown', x => { - if (x.target.classList.contains('ngn_x')) { lb.hidden = 1; upd(); pd(x); return } - if (x.target.nodeName === 'B' && t) { - let i = t.selectionStart, j = t.selectionEnd, v = t.value, s = x.target.textContent - if (i != null && j != null) { t.value = v.slice(0, i) + s + v.slice(j); t.selectionStart = t.selectionEnd = i + 1 } - pd(x); return - } - }) - let fk = x => { - let t = x.target - if (bqm) { - let i = t.selectionStart, v = t.value, c = bqc[x.key]; if (x.which > 31) { bqm = 0; d.body.classList.remove('ngn_bq') } - if (c) { t.value = v.slice(0, i) + c + v.slice(i); t.selectionStart = t.selectionEnd = i + 1; pd(x); return !1 } - } - if (!x.ctrlKey && !x.shiftKey && !x.altKey && !x.metaKey) { - if ("`½²^º§ùµ°".indexOf(x.key) > -1) { - bqm = 1; d.body.classList.add('ngn_bq'); pd(x); // ` or other trigger symbol pressed, wait for next key - } else if (x.key == "Tab") { - let i = t.selectionStart, v = t.value, c = tc[v.slice(i - 2, i)] - if (c) { t.value = v.slice(0, i - 2) + c + v.slice(i); t.selectionStart = t.selectionEnd = i - 1; pd(x) } - } - } +d.body.appendChild(el) +let t,ts=[],lb=el.firstChild,bqm=0 //t:textarea or input, lb:language bar, bqm:backquote mode +let pd=x=>x.preventDefault() +let ev=(x,t,f,c)=>x.addEventListener(t,f,c) +ev(lb,'mousedown',x=>{ + if(x.target.classList.contains('ngn_x')){lb.hidden=1;upd();pd(x);return} + if(x.target.nodeName==='B'&&t){ + let i=t.selectionStart,j=t.selectionEnd,v=t.value,s=x.target.textContent + if(i!=null&&j!=null){t.value=v.slice(0,i)+s+v.slice(j);t.selectionStart=t.selectionEnd=i+s.length} + pd(x);return } - let ff = x => { - let t0 = x.target, nn = t0.nodeName.toLowerCase() - if (nn !== 'textarea' && (nn !== 'input' || t0.type !== 'text' && t0.type !== 'search')) return - t = t0; if (!t.ngn) { t.ngn = 1; ts.push(t); ev(t, 'keydown', fk) } +}) +let fk=x=>{ + let t=x.target + if(bqm){let i=t.selectionStart,v=t.value,c=bqc[x.key];if(x.which>31){bqm=0;d.body.classList.remove('ngn_bq')} + if(c){t.value=v.slice(0,i)+c+v.slice(i);t.selectionStart=t.selectionEnd=i+1;pd(x);return!1}} + switch(x.ctrlKey+2*x.shiftKey+4*x.altKey+8*x.metaKey+100*x.which){ + case 19200:bqm=1;d.body.classList.add('ngn_bq');pd(x);break //` + case 900:{let i=t.selectionStart,v=t.value,c=tc[v.slice(i-2,i)] //tab + if(c){t.value=v.slice(0,i-2)+c+v.slice(i);t.selectionStart=t.selectionEnd=i-1;pd(x)} + break} } - let upd = _ => { d.body.style.marginTop = lb.clientHeight + 'px' } - upd(); ev(window, 'resize', upd) - ev(d, 'focus', ff, !0); let ae = d.activeElement; ae && ff({ type: 'focus', target: ae }) +} +let ff=x=>{ + let t0=x.target,nn=t0.nodeName.toLowerCase() + if(nn!=='textarea'&&(nn!=='input'||t0.type!=='text'&&t0.type!=='search'))return + t=t0;if(!t.ngn){t.ngn=1;ts.push(t);ev(t,'keydown',fk)} +} +let upd=_=>{d.body.style.marginTop=lb.clientHeight+'px'} +upd();ev(window,'resize',upd) +ev(d,'focus',ff,!0);let ae=d.activeElement;ae&&ff({type:'focus',target:ae}) })(); \ No newline at end of file From 372334d2312b526c361caa42e154da5515eb96c7 Mon Sep 17 00:00:00 2001 From: Sohang Chopra Date: Wed, 5 Jun 2024 21:09:11 +0530 Subject: [PATCH 19/20] discard formatting changes - keep original repo's code style --- index.html | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/index.html b/index.html index 7c38e30..903f008 100644 --- a/index.html +++ b/index.html @@ -1,27 +1,3 @@ - - - - ngn/apl - - - - - - - - - - - - - - -

Demo

- - - From 9780f3bb37fd693aada53c5d3e009e8faf688c3e Mon Sep 17 00:00:00 2001 From: Sohang Chopra Date: Wed, 5 Jun 2024 21:10:03 +0530 Subject: [PATCH 20/20] ignore testing scripts in testing/ folder --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 4cdc614..2f227c3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +testing/ util.sh # Created by https://www.toptal.com/developers/gitignore/api/macos