trusted
83
edits
m (→Empty frame agreement: align comments) |
m (→Model) |
||
(7 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≡⍵:' | 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←(-c)↓¨p ⍝ left and right frames | |||
k←{⍬≡⍵:99 ⋄ -≢⍵} | s←fl{⍺<⍥≢⍵:⍺ ⋄ ⍵}fr ⍝ shorter frame | ||
assert ⍺∧⍥( | k←{⍬≡⍵:99 ⋄ -≢⍵}s ⍝ relative rank | ||
⍺ | assert ⍺∧⍥(s≡(≢s)↑⍴)⍵: ⍝ do frames agree? | ||
⍺ ⍺⍺⍤c⍤k⊢⍵ | |||
} | } | ||
x+_FA_ 0 1⊢y | x+_FA_ 0 1⊢y | ||
Line 148: | Line 148: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{{Works in|[[Dyalog APL]]}} | {{Works in|[[Dyalog APL]]}} | ||
[[Category:Leading axis theory]][[Category:Function characteristics]][[Category:Conformability]]{{APL features}} | [[Category:Leading axis theory]][[Category:Function characteristics]][[Category:Conformability]]{{APL features}} |