On Fri, 24 Mar 2006 02:43:00 +0300, Mike Day <[EMAIL PROTECTED]>
wrote:
I was drafting this before Oleg's reply arrived. It's slightly
different from his, and shows a derivation of a tacit form.
==============================================================
Is this the sort of thing you need? Consider:
Yes, exactly.
d
10 7 5 6 7 1 9 8 2 4
(1 , 2 >/\ ])d NB. boolean for = left > right for each pair ?
1 1 1 0 0 1 0 1 1 0
1 1 1 0 0 1 0 1 1 0 < ;. 1 d NB. partition d by this boolean
+--+-+-----+---+-+---+
|10|7|5 6 7|1 9|8|2 4|
+--+-+-----+---+-+---+
1 1 1 0 0 1 0 1 1 0(<&(<./\);. 1)d NB. required work in boxes
+--+-+-----+---+-+---+
|10|7|5 5 5|1 1|8|2 2|
+--+-+-----+---+-+---+
1 1 1 0 0 1 0 1 1 0 ;@(<&(<./\);. 1)d NB. unbox
10 7 5 5 5 1 1 8 2 2
((1,2>/\]);@(<&(<./\);. 1)])d NB. tacit form
10 7 5 5 5 1 1 8 2 2
(;@(<&(<./\);. 1)~1,2>/\])d NB. tacit avoiding one "]" 10 7 5 5 5 1
1 8 2 2
Mike
Thanks for explanations. Your version seems to be most efficient.
--
Mikl
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm