|
From: | Elias Mårtenson |
Subject: | Re: [Bug-apl] Non-bug: Help comparing solutions |
Date: | Wed, 5 Mar 2014 13:25:51 +0800 |
X┌→─┐↓xz││zx││ab││ba│└──┘⍋⍤1 X┌→──┐↓1 2││2 1││1 2││2 1│└───┘
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:⊃p⌷¨⍨⊂¨⍋¨p←⊂[2]XAre 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]XOpinions?Regards,Elias
[Prev in Thread] | Current Thread | [Next in Thread] |