bug-apl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-apl] stacked rank operator


From: Louis de Forcrand
Subject: Re: [Bug-apl] stacked rank operator
Date: Thu, 25 Aug 2016 01:19:12 +0200

   (2 3 5 4$i.24)(+"1"_1)(2 4$i.8)
0 2 4 6
4 6 8 10
8 10 12 14
12 14 16 18
16 18 20 22

20 22 24 26
0 2 4 6
4 6 8 10
8 10 12 14
12 14 16 18

16 18 20 22
20 22 24 26
0 2 4 6
4 6 8 10
8 10 12 14


16 18 20 22
20 22 24 26
24 26 28 30
4 6 8 10
8 10 12 14

12 14 16 18
16 18 20 22
20 22 24 26
24 26 28 30
4 6 8 10

8 10 12 14
12 14 16 18
16 18 20 22
20 22 24 26
24 26 28 30

That’s the (almost surely correct) result from a J session.

Here’s an operator R which functions identically to the rank operator in J,
to which I believe the ISO operator is identical:

    ∇
[0]   Z←X(U R N)Y;M;L;R;E
[1]   (M P Q)←⌽3⍴⌽N
[2]   E←{⊂[⌽(K|(-K←K+1)⌈K⌊⍺-⍺<0)↑⌽⍳K←≢⍴⍵]⍵;K}
[3]   Z←⊃⍎(⎕IO+0≠⎕NC'X')⊃'U¨M E Y' '(P E X)U¨Q E Y'
    ∇

You guys should try every twisted operation you can on R to make sure it works.
I’ll ask the wizards in the J forum what they think.

As a side-note, I’m liking the lambda local vars. They don’t look a bit out of place.

Hope it helps,
Louis

On 24 Aug 2016, at 23:16, Xiao-Yong Jin <address@hidden> wrote:

This should work,

     (2 3 5 4⍴⍳24)(+⍤1⍤¯1)(2 4⍴⍳8)
VALUE ERROR
μ-Z__A_LO_RANK_X7_B[4]  →(μ-X7≢¯1)⍴μ-WITH_AXES
                         ^
You could use the axis operator generically

     (2 3 5 4⍴⍳24){⍺+[1,(⍴⍴⍺)⌈⍴⍴⍵]⍵}(2 4⍴⍳8)

but the rank operator seems cleaner.

Best,
Xiao-Yong




reply via email to

[Prev in Thread] Current Thread [Next in Thread]