I found this: ((1 |. 2= ] &>) +:@]^:[ &> ]) ;/ 1 2 3 2 2 4 2 1 2 2 6 4 2 8 2 1
I guess that is ok, but then I don't understand why this happens: (1 |. 2= ] &>) +:@]^:[ &> ;/ 1 2 3 2 2 4 2 1 0 0 0 0 0 0 1 1 ----- Original Message ----- From: 'Pascal Jasmin' via Programming <[email protected]> To: Programming forum <[email protected]> Cc: Sent: Monday, May 12, 2014 1:11:36 PM Subject: [Jprogramming] ^: and boxes I'm looking for this answer, but a better way to do it. > ({~"1 0 [: i.#) (<@:+:@>)^:(1 |. 2= ] &>) ;/ 1 2 3 2 2 4 2 1 2 2 6 4 2 8 2 1 the right hand side must be boxed. Unboxing at end, just there for display. Should not assume that it is possible for input. What the above is doing is if/for a cell that is equal to 2, double the previous cell. To get it to work, I've had to generate a full n x n table, and then take the diagonal. Is there a better tacit way that avoids n x n table? ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
