In action (piping throughmore detail, the entry-point is the trc to remove tab charsfunction which are the REPL's prompt):takes one argument implicitly named y.
josh@Z1c:y ~/incay#((jn<y),ly){' (V' $ cat icecream n<y } assign y to 'n' i:[( jn<y } call j(n%2)^2y)> ly } call l(y) (x-(n-1)%2 )^2, )+ } catenate the results (y- ){' (n-V' } map 0 1)%2)^2 2 to ' ' '(' 'V' y y# } reshape to NxN
The j function receives the same input value as its y parameter.
j:(~[y%2)i.(~y) k:2*[x>[|y-(n-1)%2 y%2 } y divided by 2 l: [ } floor ~ } iota. this generates the row indices 0..y/2 ~y } iota y. this generates the column indices 0..y (@1+~]y%2 )ki.(~y ) } jot-dot with the function i c
The jot-dot here does the double-loop. It calls the i function with every combination of elements from the left and right arrays (0..n/2 and 0..n). So the i function receives as x the y index of the table, and it receives as y the x index. The names got a little backwards here :).
i:y y#[((jn<yn%2),ly^2){' >+/(V' '' 'c1'qx y)^2 c1 n%2 } n divided by 2 '' (n%2)^2 } squared 'c2' x y } make a 2-element array (x,y) c2 qx y } call q on this array '' 'c3'
where q does
q:y-(n-1)%2 c3 n-1 } n minus 1 '' %2 } divided by 2 'c4' y- } y minus that c4
back to i
i:[((n%2)^2)>+/(qx y)^2 '' ( )^2 } square the result from q(x,y) 'c5' +/ } sum the two numbers c5 > } compare the left side (above) with the right (=> 0/1) [ } floor
In action (piping through tr to remove tab chars which are the REPL's prompt):
josh@Z1 ~/inca $ ./inca2 <icecream | tr -d '\t' c1 V c2 (( VV c3 ((( VVV V c4 (( (((( VVVV VV c5 ((( ((((( VVVVV VVV V josh@Z1 ~/inca $