Frame agreement: Difference between revisions

Jump to navigation Jump to search
80 bytes removed ,  14:23, 26 August 2023
m
m (→‎Model: replace with a more symmetric computation of cell ranks; no need for tables)
 
(3 intermediate revisions by the same user not shown)
Line 125: Line 125:


=== Model ===
=== Model ===
In dialects that do not feature frame prefix agreement, it can nevertheless be utilised by the introduction of an explicit operator:
In dialects that do not feature frame prefix agreement, it can nevertheless be utilised by the introduction of an explicit operator:


<syntaxhighlight lang=apl>
<syntaxhighlight lang=apl>
       _FA_←{
       _FA_←{
           assert←{0≡⍵:'no common frame prefix' ⎕SIGNAL 4 ⋄ ⍵}
           assert←{0≡⍵:'error: no common frame prefix' ⎕SIGNAL 4 ⋄ ⍵}
           r←1↓⌽3⍴⌽⍵⍵ ⋄ pp←≢¨p←⍴¨⍺⍵              ⍝ dyadic ranks, array ranks
           r←1↓⌽3⍴⌽⍵⍵ ⋄ ar←≢¨p←⍴¨⍺⍵      ⍝ dyadic ranks, array ranks, shapes
           c←r{⍺>0:⍺⌊⍵ ⋄ 0⌈⍺+⍵}¨pp                ⍝ cell ranks
           c←r{⍺>0:⍺⌊⍵ ⋄ 0⌈⍺+⍵}¨ar      ⍝ cell ranks
           fl fr←(-c)↓¨p                         ⍝ frames                       
           fl fr←(-c)↓¨p                 left and right frames                       
           s←fl{⍺<⍥≢⍵:⍺ ⋄ ⍵}fr                   ⍝ shorter frame
           s←fl{⍺<⍥≢⍵:⍺ ⋄ ⍵}fr           ⍝ shorter frame
           k←{⍬≡⍵:99 ⋄ -≢⍵}s                     ⍝ relative rank
           k←{⍬≡⍵:99 ⋄ -≢⍵}s             ⍝ relative rank
           assert ⍺∧⍥(s≡(≢s)↑⍴)⍵:                 ⍝ do frames agree?
           assert ⍺∧⍥(s≡(≢s)↑⍴)⍵:       ⍝ do frames agree?
           ⍺ ⍺⍺⍤c⍤k⊢⍵
           ⍺ ⍺⍺⍤c⍤k⊢⍵
       }
       }
      ⎕IO←0
      x←⍳2
      y←2 3 2⍴⍳12
       x+_FA_ 0 1⊢y
       x+_FA_ 0 1⊢y
  0  1
  0  1
trusted
83

edits

Navigation menu