There’s talk of the rank operator in the GNU APL forums. I wrote an
operator R in ISO APL which *should* emulate the rank conjunction
in J:

    ∇
[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'
    ∇

Hopefully the special characters go through OK. I wanted to know if
you guys (and gals) think that R looks trustworthy.

A note on the ;K in the lambda: this simply means that K is local to it.

Thanks,
Louis

> Begin forwarded message:
> 
> From: Louis de Forcrand <[email protected]>
> Subject: Re: [Bug-apl] stacked rank operator
> Date: 25 Aug 2016 01:19:12 CEST
> To: [email protected]
> 
>    (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 <[email protected] 
>> <mailto:[email protected]>> 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
>> 
>> 
> 

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to