Here's one idea of spiral order.
In it current for it has limitation that
number of items for g/ is 1+4*n
due to the way gerund is cyclically extended.

   '`d c b a'=: ( ,~ )`( ,"0 1 )`( |[EMAIL PROTECTED],] )`( |[EMAIL 
PROTECTED],"1 0~] )
   g=. (d&.>)`(c&.>)`(b&.>)`(a&.>)
   
   >g/ 3}. |.(i.@>:@{: (e.<;.2[) ]) <:+/\2#1+i.6
16 15 14 13 12
17  4  3  2 11
18  5  0  1 10
19  6  7  8  9
20 21 22 23 24
   

--- Roger Hui <[EMAIL PROTECTED]> wrote:

> Now that we have mastered zigzag order, how about the
> spiral order?  For example, the spiral order for a 
> 4 5 array is:
> 
>  0  1  2  3 4
> 13 14 15 16 5
> 12 19 18 17 6
> 11 10  9  8 7
> 
> 
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
> 



 
____________________________________________________________________________________
Do you Yahoo!?
Everyone is raving about the all-new Yahoo! Mail beta.
http://new.mail.yahoo.com
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to