Rank/Atop

From NARS2000
Revision as of 20:09, 10 April 2008 by Sudleyplace (talk | contribs) (New page: This feature is implemented via several internal magic functions: '''Monadic Derived Function''' <apll>    ∇ Z←(LO F X) R;O</apll><br /> <apll>[1]  &nbs...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

This feature is implemented via several internal magic functions:

Monadic Derived Function

    ∇ Z←(LO F X) R;O
[1]   X←1⍴X
[2]   O←⍴⍴R
[3]   X←(-O)⌈O⌊X
[4]   Z←LO¨⊂[⍳-X]R⋄→0
[5]   ⎕PROTOTYPE:Z←⊃LO¨¨⊂[⍳-X]¨0⍴⊂R
    ∇

Dyadic Derived Function

    ∇ Z←L (LO F X) R;O
[1]   X←1↓⌽3⍴⌽X
[2]   O←(⍴⍴L),⍴⍴R
[3]   X←(-O)⌈O⌊X
[4]   Z←(⊂[⍳-1↑X]L)LO¨⊂[⍳-1↓X]R⋄→0
[5]   ⎕PROTOTYPE:Z←⊃(⊂[⍳-1↑X]¨0⍴⊂L)LO¨¨⊂[⍳-1↓X]¨0⍴⊂R
    ∇

Both of the above functions implement their respective derived function except for some final processing which is essentially a disclose but one which allows for mismatched ranks. That part is implemented by the following function where L has already been calculated as the maximum rank across all items:

Internal Conform Function

    ∇ Z←L F R
[1]   Z←⊃(((L-∊⍴∘⍴¨R)⍴¨1),¨⍴¨R)⍴¨R
    ∇