[Top][All Lists]

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

Re: [Bug-apl] Non-bug: Help comparing solutions

From: Elias Mårtenson
Subject: Re: [Bug-apl] Non-bug: Help comparing solutions
Date: Wed, 5 Mar 2014 13:25:51 +0800

Referencing yesterday's discussion about ⍤, I realised that I can use it to get the indexes like this:

      ⍋⍤1 X
↓1 2│
│2 1│
│1 2│
│2 1│

However, I can't figure out a good way to apply it to the original array. Really, what is th ebest solution to this problem?


On 5 March 2014 13:06, Elias Mårtenson <address@hidden> wrote:
I was looking at the APL idiom library and found this solution to sort rows in a matrix X:

A←(⍋,X)-⎕IO ◊ (⍴X)⍴(,X)[⎕IO+A[⍋⌊A÷¯1↑⍴X]]

It looked a bit excessive to me, and I wanted to make a more clear version so I came up with this:


Are there any benefits to the previous one?

As a side note, since I'm a big fan of lambda functions, I find my second solution to be even better, but the idiom library doesn't use lambdas so it'd be a bit of apples vs. oranges:

⊃ {⍵[⍋⍵]}¨ ⊂[2]X



reply via email to

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