Rank/Atop: Difference between revisions

From NARS2000
Jump to navigationJump to search
(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...)
 
No edit summary
Line 1: Line 1:
This feature is implemented via several internal magic functions:
This operator is implemented via several internal magic functions:


'''Monadic Derived Function'''
'''Monadic Derived Function'''

Revision as of 20:09, 10 April 2008

This operator 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
    ∇