On Thu, Apr 26, 2012 at 3:31 PM, Raul Miller <rauldmil...@gmail.com> wrote: > On Tue, Apr 24, 2012 at 9:38 PM, Thomas Costigliola <tcost...@gmail.com> > wrote: >> G=. do;._2]0 :0 >> 0 1 2 2 3 4 4 5 5 6 7 7 8 9 10 10 11 11 11 12 12 12 >> 1 2 3 4 5 6 5 7 8 7 9 10 10 11 12 11 13 14 15 16 15 14 >> ) >> ]T=. </./G >> T (<@((] <@,"1 0 {:@]{::[) ::])S:_ 0^:_) <0 >> >> >> Challenge: find a verb using the same strategy without using :: and is >> shorter (or not much longer). > > You are using ::] to detect leaf nodes. > > Here's a variation on this approach: > > T=: </./ do;._2]0 :0 > 0 1 2 2 3 4 4 5 5 6 7 7 8 9 10 10 11 11 11 12 12 12 13 14 15 16 > 1 2 3 4 5 6 5 7 8 7 9 10 10 11 12 11 13 14 15 16 15 14 13 14 15 16 > ) > > ;T <@(] <@~.@,"1 0 ({::~ {:))S:1 0^:_<0 > > It might be possible to do something based on (beware line wrap): > > T=: > (<1);(<2);(3;4);(<5);(5;6);(7;8);(<7);(9;10);(<10);(<11);(11;12);(13;14;15);(14;15;16);a:;a:;a:;<a:
Yes, that was my initial approach but I couldn't find a way to use it with introducing a lot of extra, ugly code. I would be delighted if someone came up with something, I would probably have a lot of use for it. > > FYI, > > -- > Raul > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm