1 0 0 1 0 /:~ i.5
1 2 4 0 3
On Thursday, December 21, 2023 at 09:03:34 a.m. EST, 'Viktor Grigorov' via
Programming <[email protected]> wrote:
Hey,
Is there an easy way to sort an array with verb returning either 0 or 1, like
the comparison primitives?
The verb that I'd in mind relates to the 2023's advent of code's day 7: given
two equal length hands, which one has the first high card. Which one can write
as:
'K2345' ( 2 | 0 { [: I. [: , [: (<,.>)/ ,: & ('23456789TJQKA'i.]) ) 'KJ2KA'
0 NB. here meaning left is not greater right
Cheers,
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm