aboutsummaryrefslogtreecommitdiff
path: root/src/r1.bqn
blob: b173b8929454dad714f2044ab1dabafdb41146ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
# BQN runtime part 1. Requires:
#   Type Fill Log GroupLen GroupOrd _fillBy_
#   +-×÷⋆⌊⌈|<>=≠≤≥≢⊢⊣⥊∾⋈↑↓↕⊏⊑!⌜˙˜¨´`∘○⊸⟜◶⊘⍟
# Filled in by runtime: glyphs and default PrimInd
# Provides: all BQN primitives

Ind1  { 0 Fill +`(0⌈≠-1˙)↑GroupLen+`𝕩 }
/  Ind1  (Ind1)  # LIMITED to natural number list 𝕩/𝕨

Decompose  {0𝕩}
PrimInd  {𝕩}
SetPrims  {DecomposePrimInd  𝕩}
SetInv    {{swapInverse 𝕏}𝕨  inverse 𝕏}

IsArray  0=Type
IsAtom   1≤Type
Int  (1=Type)0,=
Nat  (1=Type)0,|=
ToArray  <IsAtom
IsSimple  1×´IsAtom
Deshape  IsArray{𝕩Fill𝕩}
Cell  
MatchS  1×´=¨
PermInv  1GroupOrd

_qSearch  {+´·×`𝕗(1-=)<}
_glyphLookup_  {
  {PrimInd𝕩}  ((𝕘˜𝕗_qSearch)glyphs)˙
}
_isGlyph  { (glyphs _qSearch 𝕗) = {PrimInd𝕩} }
IsJoin  '∾'_isGlyph
IsTable  '⌜'_isGlyph
DIsConst  (4=0)0('˙'_isGlyph 2)

Split2  { s2×(𝕩)÷2  s𝕩,(1+s)𝕩 }
_lookup_  {
  kvSplit2 𝕘  k _glyphLookup_ (v𝕗)
}
ScalId  @ _lookup_ 
  '+',0 , '-',0
  '×',1 , '÷',1
  '⋆',1 , '¬',1
  '⌊', , '⌈',¯∞
  '∨',0 , '∧',1
  '≠',0 , '=',1
  '>',0 , '≥',1

TabId  {
  id  (4=0)0,(IsTable 2)@,ScalId 1 Decompose 𝕩
  "´: Identity not found" ! @>id  <id
}
Identity  { 𝕨 @=Reshape,TabId𝕩˙ ScalId𝕩 }

_fold{
  "´: 𝕩 must be a list" ! 1==𝕩
  𝕨 (0<≠)1Identity 𝕗˙, 𝔽´ 𝕩
}

_eachd{
  _d{ # Equal ranks
    "Mapping: Equal-rank argument shapes don't agree" ! 𝕨 MatchS 𝕩
    𝕨𝔽¨𝕩
  }
  _e{ # 𝕨 has smaller or equal rank
    p𝕨  k=𝕨  q𝕩
    "Mapping: Argument shape prefixes don't agree" ! p MatchS kq
    l1×´kq
    ma𝕨  b𝕩
    qm (a𝔽l×+⊑b˙) l×m>0
  }
  ==>=𝔽_e𝔽˜_e˜⟩⋄𝔽_d
}

_perv{ # Pervasion
  R+IsArray
    𝔽
    {R𝕩}(>IsArray{𝕨˙R𝕩}{R(𝕩˙)𝕨}) _fillBy_ {𝕨R𝕩}
    {𝕨R _eachd𝕩} _fillBy_ {𝕨R𝕩}
  
}

# Sorting
CLE  (·=˜)≤≤  # Place NaNs after other numbers
Cmp0  CLE˜-CLE
Cmp1  (0<1×´)1, IsArray(1-2×≤){𝕨Cmp1𝕩}(0⊑⥊)
CmpLen  {
  e𝕨-(1×´0<)𝕩
  𝕨(e=0)e,0⟩‿{
    SMCmp0  ≥⊑⋈
    cr𝕨SM𝕩
    l𝕨{
      i0+´×`𝕨=¨𝕩
      m1×´i𝕨
      {klSM´𝕩ckm×l}(<⊑𝕨𝕩˙)(r>)i
      m
    }{𝕩˜(¯1+≠𝕩)-r}𝕩
    c,l
  }𝕩
}
_getCellCmp  {
  Ci𝔽c𝕨0l𝕩
  Cc{
    a𝕨b𝕩
    S(l=){S(1+𝕩)(0=)a Ci(𝕩+)b}c
    S 0
  }
  (𝕨 {𝕨(0=)𝕏} ci˙)(1=l) cc
}
Cmp  +IsArray
  Cmp0
  IsArrayCmp1,-Cmp1˜
  {
    lc𝕨CmpLen𝕩
    cc  ((𝕨))Cmp((𝕩)) _getCellCmp´ lc
    Cc˜0
  }


_grade  {
  gt  𝕗
  cmps  {𝕏˜}𝕗Cmp,Cmp0,Cmp≤0˙,CLE
  _getC_  { 𝕨 𝕘{(𝕨 𝕏 _getCellCmp 𝕗)0˙}(𝕩1) 𝔽 𝕩cmps }
  0 Fill {
    "⍋𝕩: 𝕩 must have rank at least 1" ! 1≤=𝕩
    l𝕩
    (2l)l,{
      m11=m1×´1 Cell 𝕩
      𝕩𝕩
      a01ts0{a0×1𝕩ts+𝕩}Type𝕩
      csa0+2×m1
      Merge  { # Merge sort
        le  𝕩{𝕏(𝕗)} _getC_ m cs
        Bll
        (l){
          i-d𝕨  jeiej0
          e3  GLE((m×(1-m1)𝕩))  c1-G,0,1,2
          s(8d)+,{(𝕩-1){e2jii𝕩}G(1-e)𝕩}
          N{id+𝕨ejB d+eiB jd+𝕩eljS eii R j}
          R{𝕨ec𝕩}{e+2×ei=i1+𝕨𝕨}{e+ej=j1+𝕩𝕩}N
          {(i R j)𝕩}𝕩𝕩
        }´(2ni-1+⊢)ni2 Log l+l=0
      }
      # Counting sort for small-range ints
      blbu0  Count{GroupLenGroupOrd (gt-bl,bu-)𝕩}
      sr((3=cs)×ts=l)0,(1×´=)0{((bu´𝕩)-bl´𝕩)2×l}𝕩
      srMergeCount 𝕩
    }𝕩
  }{
    cx(=𝕩)-c1-˜=𝕨
    "⍋ or ⍒: Rank of 𝕨 must be at least 1" ! 0c
    "⍋ or ⍒: Rank of 𝕩 must be at least cell rank of 𝕨" ! 0cx
    sw1 Cell 𝕨  nw𝕨
    𝕩ToArray𝕩  sxcx Cell 𝕩  lz1×´szcx↑≢𝕩
    sz  𝕨 (0<nw){𝕩0lz}{
      a0wIsSimple𝕨  Gw𝕨  lw1×´sw
      lew{𝕏Gw} _getC_ lw a0w+2×1=lw
      "⍋ or ⍒: 𝕨 must be sorted" ! 1×´LEw(lw+)(lw×)nw-1
      a0IsSimple𝕩×a0w  Gx𝕩
      cdlcsw CmpLen sx
      le  cd {Gw𝕏Gx}_getC_ lc a0+2×1=lc
      Blw×LE
      BinSearch  {
        Bx  B𝕩
        R  {aBx m𝕩+h𝕨÷2(h+a×𝕨-2×h)R a𝕩m}(>1)
        1 + (nw+1) R ¯1
      }
      (BinSearch (1×´sx)×) lz
    } 𝕩
  }
}

  0 _grade
  1 _grade

# Searching
_search{ # 0 for ∊˜, 1 for ⊐
  ind  𝕗
  red  𝕗1´,+´×`
  0 Fill {
    c1-˜=𝕨
    "p⊐𝕩 or 𝕨∊p: p must have rank at least 1" ! 0c
    "p⊐n or n∊p: Rank of n must be at least cell rank of p" ! c≤=𝕩
    n𝕨  k1×´s1 Cell 𝕨  cxc-˜=𝕩
    lx1×´shcx↑≢𝕩
    sh  𝕨 (e0<n×k)0,s MatchS cxCell{𝕩(indn>, n×e)lx}{
      cc  ((𝕨))(1-Match)((𝕩)) _getCellCmp k
      𝕨 ×(8<≠){𝕩
        ij(k×)nlx  {Red CC𝕩i}j
      }{
        gReverse⍒𝕨
        ig˜(0⌈-1)(g𝕨)𝕩
        adjind1-,⊣--n×
        i( Adj CC(k×))¨lx
      } 𝕩
    } 𝕩
  }ToArray
}
_self{
  "∊𝕩 or ⊐𝕩: 𝕩 must have rank at least 1" ! 1≤=𝕩
  g𝕩
  k1×´1 Cell 𝕩
  cc  (1-Match)((𝕩)) _getCellCmp k
  0 Fill (PermInv g)  g 𝔽 0<1, -1 CC((k×g)) ↕≠𝕩
}

Find{
  r=𝕨  d(=𝕩)-r
  "𝕨⍷𝕩: Rank of 𝕨 cannot exceed rank of 𝕩" ! 0d
  i<0  j(1×´)ds𝕩
  (𝕨) { A×𝕩(+)  i A𝕨  j A01+𝕩-𝕨 }¨ ds
  0 Fill (𝕨 Match (𝕩)˜i+<) j
}ToArray

Indices{
  "/𝕩: 𝕩 must have rank 1" ! 1==𝕩
  "/𝕩: 𝕩 must consist of natural numbers" ! 1×´Nat𝕩
  / 𝕩
}
IndicesInv{
  IA 1==𝕩
  IA 1×´Nat𝕩
  GroupLen 𝕩
}
SelfClas  (PermInv/˜˜¯1+`) _self
OccurrenceCount  (⊣-¨·`ר) _self

Transpose(1<=)ToArray,{
  l𝕩  m1×´c1 Cell 𝕩
  (𝕩)˜(c⥊↕m)+(m×)l
}_fillBy_
TransposeInv{
  r1-˜=𝕩  s𝕩  lrs  crs
  (𝕩)˜(l)+(l×)c⥊↕1×´c
}_fillBy_{IX IsArray𝕩1<=𝕩}

_reorderAxesSub_{
  "𝕨⍉𝕩: 𝕨 must have rank at most 1" ! 1≥=𝕨
  𝕨Deshape𝕨  𝕩ToArray𝕩
  "𝕨⍉𝕩: Length of 𝕨 must not exceed rank of 𝕩" ! (𝕨)r=𝕩
  "𝕨⍉𝕩: 𝕨 must consist of valid axis indices" ! 1´(Nat∧<r)𝕨
  r𝔽nGroupLen𝕨
  ka𝔾 𝕨∾/0=n
  cdk(↑⋈↓)𝕩
  lsaGroup1Stride c
  (´⌜l) (0<≠)d,((<0)+⌜´s(<+´)(×)¨)(1×´cd)⥊⊢ 𝕩
}
HandleDupAxes{
  r𝕨-0+´(0⌈-1)𝕩
  "𝕨⍉𝕩: Skipped result axis" ! (𝕩)r
  r
}
ReorderAxes  HandleDupAxes _reorderAxesSub_ 
ReorderAxesInv  {IA 10´𝕩𝕨} _reorderAxesSub_ PermInv

Prefixes{
  "↑𝕩: 𝕩 must have rank at least 1" ! 1≤=𝕩
  0Fill 𝕩 1+≠𝕩
}
Suffixes{
  "↓𝕩: 𝕩 must have rank at least 1" ! 1≤=𝕩
  l𝕩
  lFill {𝕩+l-𝕩}𝕩 1+l
}

NormIndPNormIndS{
  EIer𝕩  _cr{⊢⊣er!𝔽}
  00_cr+, >_cr  EI
}
  "𝕨⊑𝕩: Indices in 𝕨 must consist of integers"!Int,"𝕨⊑𝕩: Index out of range"
  "𝕨⊏𝕩: Indices in 𝕨 must be integers"!⌊=,"𝕨⊏𝕩: Indices out of range"

Pick0{
  "𝕨⊑𝕩: 𝕩 must be a list when 𝕨 is a number" ! 1==𝕩
  𝕩˜(𝕩)NormIndP𝕨
}
Pick1{
  "𝕨⊑𝕩: Indices in compound 𝕨 must be lists" ! 1==𝕨
  "𝕨⊑𝕩: Index length in 𝕨 must match rank of 𝕩" ! 𝕨=s𝕩
  i0𝕨{i(𝕩NormIndP𝕨)+𝕩×i}¨s
  i⊑⥊𝕩
}ToArray
PickdIsArray1,IsSimple⥊{Pickd𝕩𝕨}Pick1
PickIsArrayPick0Pickd

_multiAxis{
  glTestd1aaSingleInd  𝕗
  pre  "𝕨"gl"𝕩: "
  es  pre"𝕩 must have rank at least 1 for simple 𝕨"
  er  pre"Compound 𝕨 must have rank at most 1"
  el  pre"Length of compound 𝕨 must be at most rank of 𝕩"
  et  pre"𝕨 must be an array of numbers or list of such arrays"
  tt  d1   , et ! 1×´·⥊IsArrayaa,1×´·(1=Type) 
  Test{ # Multiple axes
    er ! 1≥=𝕨  TT 𝕨
    l𝕨𝕨  el ! l≤=𝕩
    i𝕨Ind¨pls𝕩
    ji (0<1×´i){⟨⟩˜Join1≢𝕨}, {j<0𝕨{j(j×<𝕩)+𝕨}¨𝕩j} p
    j  (1×´pls)𝕩
  }{
    es ! 1≤=𝕩
    𝕨 Single 𝕩
  }
}

FirstCell{
  "⊏𝕩: 𝕩 must have rank at least 1" ! 1≤=𝕩
  "⊏𝕩: 𝕩 cannot have length 0" ! 0<≠𝕩
  (<0)  𝕩
}
Select  "⊏"
  1×´·(1=Type)  1,0
  {(𝕩)NormIndS𝕨}  
  {𝕩NormIndS𝕨}
_multiAxisToArray
First  IsArray, (0<≠)!"⊑𝕩: 𝕩 can't be empty",0

Reverse{
  "⌽𝕩: 𝕩 must have rank at least 1" ! 1≤=𝕩
  l𝕩
  ((l-1)-l)  𝕩
}
RotReduce  {
  "𝕨⌽𝕩: 𝕨 must consist of integers" ! Int𝕨
  𝕩+0=𝕩  r𝕨-𝕩×⌊𝕨÷𝕩
  "𝕨⌽𝕩: 𝕨 too large" ! r<𝕩
  r
}
RotL  ↓∾↑
Rot  (1==)RotL(↕≠)⊏⊢,RotL
Rotate  "⌽"
  IsAtom, 0,0
  (RotReduce Rot )(0<≠)
  (RotReduce RotL ·↕⊢)
_multiAxisToArray _fillBy_ 

RepInd(2⌊=){
  𝕨(0⊑⥊)IsArray𝕨
  "𝕨/𝕩: 𝕨 must consist of natural numbers" ! Nat 𝕨
  er𝕨
  {e+r1+𝕩}{e=𝕨}˜`r×𝕩
}{
  "𝕨/𝕩: Lengths of components of 𝕨 must match 𝕩" ! 𝕩=≠𝕨
  "𝕨/𝕩: 𝕨 must consist of natural numbers" ! 1×´|=𝕨
  / 𝕨
}{
  "𝕨/𝕩: Components of 𝕨 must have rank 0 or 1" ! 0˙
}
Replicate"/"
  ((0<≠)×´(1=Type)), 1,1
  RepInd  
  RepInd
_multiAxisToArray _fillBy_ 

IsPure  {dDecompose𝕩  20, 1×´·𝕊1d˙0d}
hfils  {𝕏´{0 Fill 𝕏}}(⊢∾{𝕏˜}){𝕎{𝕎𝕏}𝕏}
HomFil  "=≠≡≢"_glyphLookup_(11230hfils){𝕎𝕩}
_fillByPure_{
  𝕘 (3≤Type){𝕨Fill𝕏},{(𝕨HomFil𝕩)_fillBy_𝕨}(IsPure⊣) 𝕗
}
_each   {𝕨𝔽(𝔽_eachd)_fillByPure_𝔽ToArray𝕩}
_table  {𝕨𝔽_fillByPure_𝔽ToArray𝕩}

match{(0𝕨)(1𝕨)𝕩}´
  =IsArray, 0
  IsArray, =
  ==      , 0
  MatchS , 0
  {1×´𝕨Match¨𝕩}

DepthIsArray0{1+0´Depth𝕩}

Join1{
  # List of lists
  "∾𝕩: 𝕩 must have an element with rank at least =𝕩" ! 0<0+´=𝕩
  ij¯1  e⟨⟩  a𝕩
  {{eDeshape a˜i𝕩j¯1}(1-i=)𝕩(jj+1)e}/≠𝕩
}

under{
  Err{𝕩}
  IsErr  (3=Type)0,Err˙=
  E  Err˙
  _errIf  {×(1-𝔽)Err˙,𝕏}
  SE  IsErr _errIf(3≥Type)

  Expand  {
    faiq𝕩  ei⊑⥊a
    IsArray⟨⟨⟩,i⟩⟩f,e,IsArray0,@Fill⥊(1×´)e,q
  }(>(IsArray 2⊑⊢))
  Expand2  {
    xfxaxixq  𝕩
    E  { faiq𝕩  {fa𝕩q _s}(1-IsStruct)(0<≠f) i }
    i  (E 1 Expand IsStruct{xfxa𝕩xq}(1⊑Decompose)) xi
    ⟨⟩‿@i‿⟨1,1
  }
  _s  {
    st,do𝕩  # Function, input depth, output is structural
    fai‿⟨q,rExpand2(2=d) (0<d) Expand 𝕗   # Path, array reference, indices, info
    {fa𝕩‿⟨q1<o,r _s}(1-IsStruct)(0<o) 𝕨 St i
  }
  IsStruct  (StructD(4=0)0,s˙=2) {Decompose𝕩}
  NS  IsStruct _errIf
  InitS  {¯1‿⟨𝕩⟩‿0‿⟨0,0 _s}
  Nest  {
    d0r0  SD  {dIsArray𝕩𝕩}
    a  Decompose(1((0<·0⊑⊣){r13𝕨SD 2𝕨},{r1𝕩}) (StructD⊣)) _perv 𝕩
    ⟨⟩‿@a‿⟨d,r _s
  }
  Es  {faiq𝕩{fa𝕩q _s}i}
  _nested  {
    p0p1(⌊⋈⌈)´pwpx0a(1 Expand 1⊑Decompose) 𝕨𝕩
    p  0+´×`(pw=⊑px)p0
    (p=p1)
      Nest 𝔽Es
      {𝕩_s}(2↑⊢)∾𝔽(2)⋈⌈¨(3⊑⊢)
    ´a
  }
  _withNest  {
    (0<+IsStruct)𝔽, Nest 𝔽(Es(1 Expand 1⊑Decompose)IsStruct)
  }
  _rankStruct_  {
    ss0  Wr{ss𝕩⟩⋄𝕩}  _rd{i𝕗{𝕩(i+1)iss}}
    _r_  {
      Min<
      𝕘 {𝕏({𝕩_s}(0 _rd))}(3≤Type)
      k𝕨((=2(0 _rd)) (0≤⊢)Min-,⊣-Min¨ 𝔾_ranks)𝕩
      c0<+´ssEnc0 _rdEncRank,{faiq𝕩{fa𝕩q _s}𝕨 EncRank i}
      cMerge,{𝕏Merge,21}Nest ((0k)Enc𝕨) 𝔽_each ((1-˜)k)Enc𝕩
    }
    𝕨 𝔽_r_𝔾((1 Expand 1⊑Decompose)(Wr IsStruct)) 𝕩
  }
  _depthStruct_{
    n𝕨𝔾_ranks𝕩  F𝔽  B{𝕏}{𝕨˙𝕏}
    "Under ⚇: depths must be less than 0, or ∞"!1×´(=∨0>)n
    _tf{𝕗⌜_withNest}  _ef{𝕗_eachd _withNest}
    a  {(𝕨 B 𝕗)_tf𝕩}{𝔽(𝕩˙)_tf𝕨}_ef
    _d{ t2×+´0>𝕗  𝕗{𝕩m(t-1)a(+1𝕗)_d _m}(0<t) f }
    𝕨 n _d 𝕩
  }

  _amb  {(IsStruct⊢)𝕏, 𝕩𝕗{𝕨𝕏𝕗}}
  _mon  {(𝕗_amb𝕩)(NS𝕩)}
  _dy   {(NS𝕩)(𝕗_amb𝕩)}
  kv  Split2 
    "⊢⊣˜∘○⊸⟜⊘◶",    # ˙ handled specially
    "´˝",         {r𝕩{IsArrayE,𝔽_r}}
    "=≠≢",        10 _mon
    "<",          02 _mon
    "⋈",          02 {+IsStruct𝕏, 𝕩𝕗{𝕏𝕗}E, Nest 𝕏}
    "≍",          11 _mon  # Dyad combines
    "↕/»«",       11 _dy
    "⊔",          12 _dy
    "⥊⌽⍉⊏",       11 _amb
    "↑↓",         {(12 _amb𝕩)(11 _amb𝕩)}
    "⊑",          12 _amb
    ">",          21 _mon
    "∾",          21 {+IsStruct𝕏, 𝕩𝕗{𝕏𝕗}E, 𝕏_nested}
    "¨⌜",         {m𝕩{𝔽 _m _withNest}}
    "˘",          {𝕩{𝔽 _rankStruct_ ¯1}}
    "⎉",          rankStruct˙
    "⚇",          depthStruct˙
  
  NSPrim  (Type-3˙)NS, {m𝕩{NS(𝕗_m)˙0}}, {m𝕩{NS(𝕗_m_𝕘)˙0}}
  SP  (Join1 k)_glyphLookup_((k/v)NSPrim)

  Recompose  
                      # 0 primitive
                      # 1 block
    {𝕎𝕏}´             # 2-train
    {FGH𝕩F G H}    # 3-train
    {Fm𝕩F _m}       # 4 1-modifier
    {FmG𝕩F _m_ G}  # 5 2-modifier
  
  Recomp  (E˙=≥3)Recompose,E˙

  SFN  03,22(0⊑⊢)
    SE · {pSP𝕩P𝕩} 1⊑⊢           #  0 primitive
    E˙                            #  1 block
    DIsConstSE 0 Recomp {SFN1𝕩}, {(1𝕩)˙}  # other operation
    SE 1⊑⊢                        # ¯1 constant
  {Decompose𝕩}

  # Traverse indices 𝕩 and values 𝕨.
  # Return flat lists ⟨indices,values⟩, or err if 𝕨 doesn't capture 𝕩.
  conform  {𝕎0𝕏}´IsArray⊢, ==, MatchS
  GetInserts  {
    vd𝕨
    count1DCIsArray0,d1,1+0´{count+¯1+≠d𝕩DCd}⟩⟩⋄depthDC𝕩
    𝕩 (2depth)()(ConformErr˙,){
      Fail{𝕊0}
      # 𝕎 is parent traversal; 𝕩 is current components of ind and val
      Trav(IsArray 0⊑⊢), Conform´Fail{
        Parent𝕎  n0a𝕩  j¯1
        ChildTrav{𝕩a}
        { j+1  fn𝕊˙Child,Parent˙j  F 0 }
      }
      next  0 Trav 𝕨𝕩
      res  {noNext𝕩nextno} count
      (next=fail)0  1, Err˙ res
    } v
  }(1-IsErr)

  _insert_  {
    iv𝕗_indRec𝕘 𝕩
    rootx𝕗
    Set1{
      𝕩ToArray𝕩
      s𝕩ld𝕩
      "Cannot modify fill with Structural Under"!1´@>i
      gll GroupLen i  v˜gl GroupOrd i
      j0Adv{(j+𝕩)-1}v˙
      CM"⌾: Incompatible result elements in structural Under"!Match
      s(l)2d,Adv,Adv{(𝕨CM(j-𝕩)+⊑v˙)𝕩-1𝕨}¨gl
    }
    _at_  {(↕≠𝕩)𝔽((𝔾𝕩)=⊣)¨𝕩}
    Set  0{ (𝕨≥≠root)≢⥊(1+𝕨)𝕊_at_(𝕨root˙), Set1 _fillBy_  𝕩 }
    IsArrayroot0v˙, Set x
  }

  _indRec  {
    rootx𝕗  iv𝕩
    l  GroupLen i  (1=Type)001⊑Decompose,¯1 0iv
    indval  (l GroupOrd i) iv  rec0
    ic  (1<·0⊑⊢)2⊑⊢,{rec1𝕩_s}(10⊑⊢)1↓⊢(1⊑Decompose) ind
    j0  IJ{(j+𝕩)  val 1GetInserts((j+𝕩)) ic}
    m  (  (x) {⟨⟩‿𝕨 _insert_ rec(1-IsErr) 𝕩} ·IJ⊑l) /0<l
    t  (/ ¯1=i) iv
    {(𝕩m)𝕩t} 2
  }

  {
    val𝕨𝔽𝔾𝕩
    s𝕘 SFN{𝕎𝕩} InitS 𝕩
    rootind‿⟨d,rec  IsStruct0Err‿⟨0,0⟩,0231⊑Decompose s
    IsErrroot𝕩 _insert_ rec, {𝕏val}·Inverse𝔾˙ vald GetInserts ind
  }
}

  Depth           Match
  IsArray(0)  (1-Match)

IF  ⊢⊣!  # Intersect fill
IEF (0<≠)_fillBy_ Fill, _fillBy_ IF´
HasFill  0=·Fill⊢_fillBy_(@(3≤Type))(0)
_fillMerge_  {(0<≠)(𝔾≢⥊⟨⟩˙)_fillBy_FillHasFill, 𝔽 _fillBy_ IEF}
Merge{
  c0⊑⥊𝕩
  (">𝕩: Elements of 𝕩 must have matching shapes" ! c =0MatchS )𝕩
  (Deshape𝕩)˜⌜c⥊↕1×´c
}_fillMerge_IsArray

JoinTo(1<⌈=)(){
  a1-˜𝕨=𝕩
  s𝕨𝕩
  "𝕨∾𝕩: Rank of 𝕨 and 𝕩 must differ by at most 1" ! 1×´(a≤≠)s
  c(≠-a˙)s
  "𝕨∾𝕩: Cell shapes of 𝕨 and 𝕩 must match" ! MatchS´c
  l0+´(a<≠)1(0⊑⊢)s
  (l0c)𝕨𝕩
}ToArray _fillBy_ IF

_s0{s𝕨F𝔽{oss F𝕩o}𝕩}
StrideReverse 1 ×_s0 Reverse
JoinM{
  # Multidimensional
  nz𝕩  sz  r=𝕩
  sh𝕩  p1  ijhe<0
  (Stride sh){
    q𝕨
    a𝕩sh
    h-(1-˜0´rr)rr=z˜q×a
    "∾𝕩: Incompatible element ranks" ! 1×´0h
    hlihq×/h
    sfs˜((a×q)×p)+ih+q
    sihehl×q
    "∾𝕩: Incompatible element ranks" ! 1×´si<¨sf
    msi¨sf
    lfm˜q×hl
    "∾𝕩: 𝕩 element shapes must be compatible" ! m MatchS (p)lfq
    k  / l{i¯11{(i+𝕩)lf}h}
    c  (↕≠k)-¨k  0+_s0 l
    he he + h
    i  (i × kl) +¨ ic
    j  j ×a+ k
    p×a
  }¨r
  d(=0z)-0hehe
  "∾𝕩: 𝕩 element trailing shapes must match" ! he MatchS (=-d˙)z
  G(Deshapez){𝕨𝕩𝕗}¨
  i (0<d)G{
    Tr(≠-d˙)tTr 0s
    "∾𝕩: 𝕩 element trailing shapes must match" ! 1×´(t MatchS Tr)s
    tit⥊↕tp×´t(𝕨tp×+ti)G𝕩ti
  } j
}
Join(2⌊=)
  Merge, (1×´(1≥=))JoinMJoin1, JoinM
_fillMerge_{
  r𝕨  d𝕩
  "∾𝕩: empty 𝕩 fill rank must be at least argument rank" ! dr
  (d)(r≤⊣)𝕨×,¨𝕩
}  "∾𝕩: 𝕩 must be an array"!IsArray

_takeDrop{
  take  1 - 𝕗
  gl    𝕗"↑""↓"
  noop  𝕗1-=|, 1-0=
  inds  𝕗
    { 𝔽(𝕨<)a|𝕩  (0<𝕩)¯∞(<0)+(𝕨+𝕩), ¯∞(𝕨)a }
    { 𝔽  0<0⌈+,<⊢+·0⌈- }
  
  pre  "𝕨"gl"𝕩: 𝕨 must "
  ernk  pre"have rank at most 1"
  eint  pre"consist of integers"
  IsArray{
    eint ! Int 𝕨
    p0𝕨
    l𝕨p0⌈+,𝕩
    F𝕩{(Fill𝕗)˙⌜𝕩}
    k1S  𝕨{k×´c1 Cell𝕩  S((0(𝕩)-⊢)(1-take)|𝕨c)}(1<=) 𝕩
    S ((|𝕨-≠𝕩){𝕩p˜,F𝕨×k}(>0))take (l×k) (take=p) 𝕩
  }{
    ernk ! 1≥=𝕨
    𝕨  𝕨
    eint ! 1×´Int𝕨
    r  𝕨
    s  r {(1𝕨-≠𝕩)𝕩}(>) 𝕩
    _c  { (×𝕗𝕨) + 𝕩 }
    i<0  k1  UIk{ i (k×𝕨)_c k (𝕨_c)(1-=1) 𝕩  k1  𝕩 }
    doFil0
    sh  (rs) Noop{k×𝕨𝕨}( UIk {𝕩doFil1}_inds)¨ 𝕨
    (0<=i)(s){
      sh  t  rs
      {i 𝕩_c 𝕩}(1-1=) k×´t
      Sel  (𝕩)
      𝕩{Sel0(Fill𝕨)˙,Sel}doFil
      Sel sh  i
    } 𝕩
  }_fillBy_  ToArray
}
Take  0 _takeDrop
Drop  1 _takeDrop

ShiftCheck{
  "« or »: 𝕩 must have rank at least 1" ! 1≤=𝕩
  s1 Cell 𝕩
  𝕨 {  # Only if called with two arguments
    "« or »: 𝕨 must not have higher rank than 𝕩" ! 0𝕩
    "« or »: Rank of 𝕨 must be at least rank of 𝕩 minus 1" ! 1𝕩
    "« or »: 𝕨 must share 𝕩's major cell shape" ! s MatchS (1-𝕩)↓≢𝕨
  } 𝕩-=𝕨
  (𝕨1{(𝕩=⊢)1𝕨}𝕩) ×´ s
}
ShiftBefore{
  n𝕨 ShiftCheck 𝕩
  mnld𝕩
  (𝕩)  (𝕨{(Fill𝕩)𝕨}(0<l)𝕩(Deshape˜)m)  (l-m)d
} _fillBy_ (IF)
ShiftAfter{
  n𝕨 ShiftCheck 𝕩
  mnld𝕩
  (𝕩)  (md)  𝕨{(Fill𝕩)𝕨}(0<l)𝕩(n-Deshape˜)m
} _fillBy_ (IF)

RangeCheck  "↕𝕩: 𝕩 must consist of natural numbers"!Nat
Range  IsArray(↕⊣RangeCheck){
  "↕𝕩: 𝕩 must be a number or list"!1==𝕩  RangeCheck𝕩
  (0𝕩)Fill 0Fill(0<1×´)⟨⟩,(<⟨⟩)⌜´𝕩
}
Windows{
  "𝕨↕𝕩: 𝕨 must have rank at most 1" ! 1≥=𝕨
  r𝕨Deshape 𝕨  𝕩ToArray𝕩
  𝕨{
    "𝕨↕𝕩: Length of 𝕨 must be at most rank of 𝕩" ! r≤=𝕩
    "𝕨↕𝕩: 𝕨 must consist of natural numbers" ! ×´Nat𝕨
    s𝕩
    l(rs)(1+-)¨𝕨
    "𝕨↕𝕩: Window length 𝕨 must be at most axis length plus one" ! ×´0l
    k1×´trs
    Win  {
      str  Reverse ×`ks˜{𝕩-𝕩}r-1
      (𝕩) ˜ k +(t⥊↕)˜(1-=1) l +(+⌜´str{𝕨×𝕩}¨) 𝕨
    }
    𝕨 (0<(k×´l)×´){⟨⟩˜l𝕨t},Win 𝕩
  }_fillBy_(0<r)𝕩
}

EncCell  {
  f𝕨↑≢𝕩  c1×´s𝕨Cell𝕩  d𝕩
  is⥊↕c
  E{eFill d_fillBy_(0(3≤Type))0  (d_fillBy_˜e˙⌜i)Fill𝕩}
  f E(0=≠) {d˜(c×𝕩)+i}1×´f
}
EncRank  (>0×1+≥=)<⊢,EncCell,<_fillBy_<⊢
_cells  {
  F𝔽  _m{𝔽(𝔽¨)_fillByPure_𝔽(1EncCell)}
  D{ "˘: Argument lengths don't agree" ! 𝕩=𝕨  𝕨 F _m 𝕩 }
  Merge 𝕨 2×+(0<=)<F,{𝕨˙F _m𝕩},{F(𝕩˙)_m𝕨},D 𝕩
}
_insert{
  "˝: 𝕩 must have rank at least 1" ! 1≤=𝕩
  F𝔽
  Id  {
    s  1↓≢𝕩
    JoinSh  {"˝: Identity does not exist"!0<≠𝕨  𝕨×(0<)¨↕≠𝕨}
    s (1-IsJoin)JoinSh⥊𝕩˙, Identity f
  }
  𝕨 (0<≠)1Id{𝕨F´1 EncCell 𝕩} 𝕩
}

ReshapeT  "∘⌊⌽↑"_glyphLookup_(5)
Reshape{
  "𝕨⥊𝕩: 𝕨 must have rank at most 1" ! 1≥=𝕨
  sDeshape 𝕨
  sp0+´p(1-Nat)s
  "𝕨⥊𝕩: 𝕨 must consist of natural numbers" ! 1sp
  ndDeshape 𝕩
  lsp(1×´){
    lp1×´p1¨𝕩
    "𝕨⥊𝕩: Can't compute axis length when rest of shape is empty" ! 0<lp
    i0+´pר↕≠p
    tReshapeT is
    "𝕨⥊𝕩: 𝕨 must consist of natural numbers or ∘ ⌊ ⌽ ↑" ! t<4
    Chk    "𝕨⥊𝕩: Shape must be exact when reshaping with ∘" ! =
    a(2t)Chk,,n÷lp
    spa¨s
    {d(Fill d)𝕩-nn}(n<)(3=t)lp×a
  } s
  s{
    "𝕨⥊𝕩: Can't produce non-empty array from empty 𝕩" ! 0<n
    l >, (⊢∾-≠↑⊢)÷2{𝕨𝕊(˜)(>)𝕩} 𝕩
  }_fillBy_(1-l=n) d
}

_group{
  "⊔: Grouping argument must consist of integers" ! 1×´Int𝕩
  "⊔: Grouping argument values cannot be less than ¯1" ! 1×´¯1𝕩
  GLGroupLen𝕩𝕨(-˜{GL(0𝕨𝕩)GL⊢𝕨𝕩})(0)𝕩
  d(lGL𝕩)GroupOrd𝕩
  i0(𝔽d˜{(i+𝕩)i+𝕩})l
}
GroupInds{
  "⊔𝕩: 𝕩 must be a list" ! 1==𝕩
  G_group
  (1<≡)
    0             Fill G
    ((⊢Fill⥊⟨⟩)0) Fill (<<⟨⟩) ⌜⌜´ {(⥊Range≢𝕩) G⥊𝕩}ToArray
   𝕩
}
Group1{
  n=𝕨
  "𝕨⊔𝕩: Rank of simple 𝕨 must be at most rank of 𝕩" ! n≤=𝕩
  ld(𝕨)-¨ns𝕩
  dr(1=n)0,1=0ld
  "𝕨⊔𝕩: Lengths of 𝕨 must equal to 𝕩, or one more only in a rank-1 component" ! dr1×´0=,1ld
  SX((n==𝕩){c1×´tns𝕩˜(c×+)(t⥊↕c)}{𝕩} 𝕩) _fillBy_ 𝕩
  (SX⟨⟩) Fill dr SX _group 𝕨
}ToArray
GroupM{
  "𝕨⊔𝕩: Compound 𝕨 must be a list" ! 1==𝕨
  n0+´r=𝕨
  "𝕨⊔𝕩: Total rank of 𝕨 must be at most rank of 𝕩" ! n≤=𝕩
  ld(Join1≢𝕨)-¨n↑≢𝕩
  "𝕨⊔𝕩: Lengths of 𝕨 must equal to 𝕩, or one more only in a rank-1 component" ! 1×´ld((0≤⊣)×≤)¨r/1=r
  drr¨(0+_s0 r)ld0
  ldr-˜¨𝕨Deshape𝕨  LS(n Cell 𝕩) Reshape 𝕩˙
  S(LS1×´l)
  (LS 0𝕨) Fill dr (1≠≠)
    S _group(0)
    S ·+⌜⌜´ (Stride l) {𝕨×⌜⌜𝕩}¨ _group¨
   𝕨
}
GroupGen{
  "𝕨⊔𝕩: 𝕩 must be an array" ! IsArray 𝕩
  𝕨(2≤≡𝕨)Group1GroupM𝕩
}

GroupIndsInv  {
  IA 1==𝕩
  IX 1×´(1==)𝕩
  jJoin1 𝕩
  IA 1×´(1≠=)j
  IX 1×´Natj
  {IX𝕨<𝕩𝕨}´(0<≠)𝕩
  gGroupLen j
  IX 1×´1g
  o/1-g
  (PermInv jo)(/≠𝕩)¯1o
}
GroupInv  {
  IA 1==𝕨
  IA 1×´Nat𝕨
  lGroupLen𝕨
  IX l=𝕩
  IX l MatchS 𝕩
  (PermInv l GroupOrd 𝕨)  Join 𝕩
}

ValidateRanks{
  "⎉ or ⚇: 𝔾 result must have rank at most 1" ! 1≥=𝕩
  𝕩Deshape𝕩
  "⎉ or ⚇: 𝔾 result must have 1 to 3 elements" ! (1≤×≤3)𝕩
  "⎉ or ⚇: 𝔾 result must consist of integers" ! 1×´Int𝕩
  𝕩 ˜ (𝕩)(-+1-˜÷˜×⊣) 𝕨
}
_ranks  {21,0 ValidateRanks 𝔽}
_depthOp_{
  neg0>n𝕨𝔾_ranks𝕩  F𝔽  B{𝕏}{𝕨˙𝕏}
  fb((3≤Type)1IsPure𝕗){𝕘𝔽}{𝔽_fillBy_𝔾}
  _tf{𝕗_fb_𝕗}  _ef{𝕗_eachd _fb_ 𝕗}
  _d{
    r0  GR𝕗{𝕩gr0R(𝕗+¨neg)_d}
    TwTx0(2>≠)neg{(𝕨×0𝕩)(0𝕩)<≡,0}¨𝕗
    (2×Tw)+Tx
      F, {GR 0(𝕨 B r)_tf𝕩}, {GR 0R(𝕩˙)_tf𝕨}, {GR 0𝕨R _ef𝕩}
    
  }
  𝕨 n _d 𝕩
}
_rankOp_{
  Min<
  k𝕨(= (0≤⊢)Min-,⊣-Min¨ 𝔾_ranks)𝕩
  Merge ((0k)EncRank𝕨) 𝔽_each ((1-˜)k)EncRank𝕩
}

_repeat_{
  F𝔽  b𝕨{𝕏⊣}˙{𝕨˙{𝔽𝕏⊣}}0
  n𝕨𝔾𝕩
  Multi{
    lu0
    {"⍟: 𝕨𝔾𝕩 must consist of integers"!Int𝕩l𝕩u𝕩}_perv n
    i𝕩⟩⋄PB{𝕎`i∾↕𝕩}
    posf P u
    negf 0<i,InverseP -l
    (|⊑<0posneg˙)_perv n
  }
  (Nat n)Multi{𝕩(B f)´n} 𝕩
}

÷  ÷ _perv
   _perv
  (÷2)    (÷˜)
|  (|        (>|{𝕩-𝕨×⌊𝕩÷𝕨}(+(<00>,0<))) ) _perv
  (        (<)) _perv
  (--    (>)) _perv
         (× _perv)
         ((+-×) _perv)
×  (0(<->)  ×) _perv
<  <         ((1-≥) _perv)
>  Merge     ((1-≤) _perv)
           ((1-=) _perv)
=  =         (= _perv)
  !"≥: Needs two arguments"  ( _perv)
  !"≤: Needs two arguments"  ( _perv)
+  + _perv
-  - _perv
¬  1+-

  SelfClas        (1 _search)

ProgressiveIndexOf  0 Fill {
  c1-˜=𝕨
  "⊒: Rank of 𝕨 must be at least 1" ! 0c
  "⊒: Rank of 𝕩 must be at least cell rank of 𝕨" ! c≤=𝕩
  𝕨(¨(≢⥊OccurrenceCount) 𝕨)𝕩
}

  {Inverse 𝕗}
IsConstant  (3≤Type)1  DIsConst{Decompose𝕩}
AtopInverse  {(𝕏𝕎)(𝕏𝕎)}{Inverse𝕩}
TrainInverse  {
  tfgh𝕩
  K¬IsConstant
  f K{𝕏{𝕨𝔽𝔾𝕩}(𝕨G)},K{𝕎𝕩G{SwapInverse𝕗}},INF˙⟩⟩ h
}
FuncInverse  (0 
  {PrimInverse𝕩} 1                     # 0 primitive
  (!"Can't invert blocks (add an undo header?)")˙  # 1 block
  1 AtopInverse 2                    # 2-train
  TrainInverse                           # 3-train
  1    {𝕏𝕨}{Mod1Inverse𝕩} 2         # 4 1-modifier
  13 {𝕏´𝕨}{Mod2Inverse𝕩} 2         # 5 2-modifier
 ) {Decompose𝕩}
Inverse  Type(312/{⊢⊣𝕩IX≡⊢}FuncInverse(!"Cannot invert modifier"))

IA  "⁼: Inverse failed"!
IX  "⁼: Inverse does not exist"!
INF "⁼: Inverse not found"!0˙
_invChk_  {i𝕨𝔽𝕩IX 𝕩𝕨𝔾ii}
  Range           Windows
  FirstCell       Select _fillBy_ 
  Reverse         Rotate
  Prefixes        Take
  Suffixes        Drop
PrimInverse  INF _lookup_ 
  '+', +(-˜)
  '-', -
  '×', _invChk_×(÷˜)
  '÷', ÷
  '⋆', Log _perv
  '√', ט(˜)
  '∧', _invChk_(÷˜)
  '∨', _invChk_(-˜÷1-⊣)
  '¬', ¬
  '≠', {B0=∨1=IX B𝕩IA B𝕨𝕩𝕨} _perv
  '<', {IX IsArray𝕩IX 0==𝕩0⊑⥊𝕩}(IA0)
  '⊢', 
  '⊣', (⊢⊣IX)
  '∾', IA0  {d𝕩-=𝕨IX(0≤∧≤1)dld1𝕨IX l≤≠𝕩IX (ToArray𝕨)dl,𝕩l𝕩}
  '≍', {IX  1 =≠𝕩 𝕩}  {IX  2 =≠𝕩IX 𝕨 𝕩1𝕩}
  '⋈', {IX 1≡≢𝕩0𝕩}  {IX 2≡≢𝕩IX 𝕨0𝕩1𝕩}
  '↑', ¯1_invChk_  (IA0)
  '↓',  0_invChk_  (IA0)
  '↕', _invChk_  (IA0)  # Should trace edge and invChk
  '⌽',   (-  IXIsArray)
  '⍉', TransposeInv  ReorderAxesInv
  '/', IndicesInv  (IA0)
  '⊔', GroupIndsInv  GroupInv

SwapInverse  INF _lookup_ 
  '+', ÷2(-˜)
  '-', IA0+
  '×', (÷˜)
  '÷', IA0×
  '⋆', IA0
  '√', IA0(÷Log)
  '∧', (÷˜)
  '∨', (¬√¬)(-˜÷1-⊣)
  '¬', IA0(+-1˙)

  _table
¨  _each
  Join            JoinTo
»  ShiftBefore
«  ShiftAfter
Mod1Inverse  INF˙ _lookup_ 
  '⁼', 
  '˜', {SwapInverse𝕩}
  '¨', {𝕏⁼¨                     ·IX 0<≡}
  '⌜', {𝕏⁼⌜(IA0)              ·IX 0<≡}
  '˘', {(IXIsArray⊢𝕏)˘       ·IX 0<=}
  '`', {(⊏∾¯1↓𝕏1)(1<≠)(»𝕏⊢)·IX 0<=}{𝕏⁼¨}

  _repeat_
  _under_
Mod2Inverse  INF˙ _lookup_ 
  '∘', AtopInverse
  '○', {Fi𝕎𝕏 Fi(𝕏Fi)}
  '⌾', {𝕎𝕏}  # Need to verify for computational Under
  '⍟', IntIA0˙,{𝕎(-𝕩)}
  '⊘', {(𝕎)(𝕏)}
  '⊸', IsConstant {INF𝕏} {𝕎(𝕏)}
  '⟜', {(𝕨IsConstantIA0˙,{𝕩𝕎{SwapInverse𝕗}}𝕩)(𝕏𝕎)}


´  _fold
˝  _insert
  {iInverse𝕗𝕨I𝕩}
˘  _cells
  First           Pick
  {𝕨((𝕨𝔽𝕩)𝕘){𝔽}𝕩}  # Same definition, new Pick
  _depthOp_
  _rankOp_
  Deshape         Reshape
  > _fillBy_ (IF)
  {𝕩Fill𝕩}      ( _fillBy_ IF<)
  GroupInds       GroupGen
  Transpose       ReorderAxes
  _self          (0 _search˜)
  /             Find
  OccurrenceCount ProgressiveIndexOf
/  Indices         Replicate