Frame agreement: Difference between revisions
Jump to navigation
Jump to search
m (→Model: replace obscure variable names; remove extra whitespace) |
m (→Model) |
||
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 ⋄ ⍵} | ||
r←1↓⌽3⍴⌽⍵⍵ ⋄ ar←≢¨p←⍴¨⍺⍵ ⍝ dyadic ranks, array ranks, shapes | |||
c←r{⍺>0:⍺⌊⍵ ⋄ 0⌈⍺+⍵}¨ar ⍝ cell ranks | |||
fl fr←(- | fl fr←(-c)↓¨p ⍝ left and right frames | ||
s←fl{⍺<⍥≢⍵:⍺ ⋄ ⍵}fr ⍝ shorter frame | |||
k←{⍬≡⍵:99 ⋄ -≢⍵} | k←{⍬≡⍵:99 ⋄ -≢⍵}s ⍝ relative rank | ||
assert ⍺∧⍥( | assert ⍺∧⍥(s≡(≢s)↑⍴)⍵: ⍝ do frames agree? | ||
⍺ ⍺⍺⍤c⍤k⊢⍵ | ⍺ ⍺⍺⍤c⍤k⊢⍵ | ||
} | |||
} | } | ||
⎕IO←0 | ⎕IO←0 |