-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
husk.dyalog
24 lines (18 loc) · 1.36 KB
/
husk.dyalog
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
(tcs lbs)←Build commands;ins;table;nums;n
⍝ ⍵ is select, copy and paste from https://github.com/barbuz/Husk/wiki/Commands
n←⎕UCS 10 ⍝ newline
commands↓⍨←1 ⍝ remove header
commands⌿⍨←''∘≢¨commands[;1] ⍝ remove non-symbol commands
commands[;2]~←' ' ⍝ trim
commands[;2]←{×≢⍵:3↑⍵,'.' ⋄ ⍵}¨commands[;2] ⍝ force length-3 tab shortcuts
commands⌿⍨←~commands[;1]≡¨⊂'0-9 ' ⍝ remove digits' row
nums←⍪'Nul' 'One' 'Two' 'Thr' 'Fou' 'Fiv' 'Six' 'Sev' 'Eig' 'Nin' ⍝ digit names
ins←commands[;1]⍳⊂'⁰-⁹ ' ⍝ find superscripts
table←'⁰¹²³⁴⁵⁶⁷⁸⁹',nums,⍤1⊢¯2 0 ¯1↓¨commands[ins;3 4 5] ⍝ construct table
commands←(¯1↓ins↑commands)⍪table⍪ins↓commands ⍝ insert
ins←commands[;1]⍳⊂'₀-₉ ' ⍝ find subscripts
table←'₀₁₂₃₄₅₆₇₈₉',(819⌶nums),⍤1⊢¯2 0 ¯1↓¨commands[ins;3 4 5] ⍝ construct table
commands←(¯1↓ins↑commands)⍪table⍪ins↓commands ⍝ insert
commands[;1]⍴⍨←⊂⍬ ⍝ scalar symbols
lbs←,/commands[;1 1],n,¨commands[;3 4 5] ⍝ construct tips
tcs←∊commands[;2 1]⌿⍨×≢¨commands[;2] ⍝ construct tab completions