Frame agreement: Difference between revisions

Jump to navigation Jump to search
6 bytes added ,  14:19, 26 August 2023
m
m (→‎Model: replace obscure variable names; remove extra whitespace)
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:


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

edits

Navigation menu