zz is Oleg's solution. f can be rendered readily
in C.
zz=: ($ [: /:@; [: <@|.`</. i.)@,~
f=: 3 : 0
n=. <:2*y
p=. (2!1+i.n) - (-n){.2*2!i.&.<:y NB. <.//.zz y
q=. }.<:p,>:{:p NB. >.//.zz y
z=. (y,y)$0
for_i. i.y do.
for_j. i.y do.
k=. i+j
c=. 0>.k-y-1
if. 2|k do. z=. z (<i,j)}~ (k{p)+i-c
else. z=. z (<i,j)}~ (k{q)-i-c end.
end.
end.
)
f 5
0 1 5 6 14
2 4 7 13 15
3 8 12 16 21
9 11 17 20 22
10 18 19 23 24
(f -: zz)"0 i.20
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
----- Original Message -----
From: bill lam <[EMAIL PROTECTED]>
Date: Saturday, November 25, 2006 9:00 am
Subject: Re: [Jprogramming] zig-zag order
> bill lam wrote:
> > Thanks to everyone for input. I can see how to use /. and /: now.
> >
> > btw
> >
> sorry hitting the send button accidentally.
>
> btw anyone knows how to do it in C or have a pointer? May be this
> serves as an
> example of "C for J Programmers" :-)
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm