|
Rank Operator: An Idea Worth
Abstract 2. Examples
x←2 3 4⍴⍳24
(⍉rank 2) x
0 4 8
1 5 9
2 6 10
3 7 11
12 16 20
13 17 21
14 18 22
15 19 23
⍉[1]x
SYNTAX ERROR
⍉[1]x
∧
(+/∘, rank 1) x
6 22 38
54 70 86
(+/∘, rank 2) x
66 210
⎕←a←↑ 'the' 'time' 'has' 'come' 'for' 'rank'
the
time
has
come
for
rank
⍋ a
3 4 2 5 0 1
(⍋ rank 1) a
3 2 1 0
3 1 2 0
3 1 0 2
0 3 2 1
3 0 1 2
1 3 2 0
({⍵[⍋⍵]} rank 1) a
eht
eimt
ahs
cemo
for
aknr
2. Model
effrank ←{(0≤⍺)⊃(0⌈⍺+⍴⍴⍵)(⍺⌊⍴⍴⍵)}
cells ←{⊂[(-⍺ effrank ⍵)↑⍳⍴⍴⍵] ⍵}
assemble←{↑ ((1⍴¨⍨r-⍨⌈/,r←⍴∘⍴¨⍵),¨⍴¨⍵)⍴¨⍵}
rank←{
(m l r)←⌽3⍴⌽⍵⍵
0=⎕NC'⍺' : assemble ⍺⍺¨ (m cells ⍵)
assemble (l cells ⍺) ⍺⍺¨ (r cells ⍵)
}
3. Applications
outer product 4. I.R.S. Integrated Rank Support (IRS) was 5. History Iverson introduced function rank
in section 6 of his seminal
Operators and Functions research report
[2]
on 1978-04-26.
The rank operator was invented by Arthur Whitney
[3,
4]
in July 1982 while on a train to the APL82 conference in Heidelberg.
It was first published in
Rationalized APL
[5]
on 1983-01-06, and the first implementation
was released in SHARP APL on 1983-05-02
[6].
It is described in Sections 9.3.3, .4, and .5 of
the ISO Standard on Extended APL
[7].
References
The text requires the APL385 Unicode font,
which can be downloaded from
http://www.vector.org.uk/resource/apl385.ttf .
To resolve (or at least explain) problems with displaying
APL characters see
http://www.vector.org.uk/archive/display.htm .
|