On Fri, May 4, 2012 at 6:36 PM, Joe Groff <arc...@gmail.com> wrote: > Thanks! I was trying to cook something up like that myself. Here's a > tweaked version that works with heterogeneous ranks: > > --- > powmod2 =: 1 :(':';'(m|*)/(|.(i.<:#$b)|:b)^~(m|*:)^:(<{:$b=.#:y) x') > 5 6 7 (10 powmod2) 3 2 $ 40 0 0 41 42 0 > 5 1 > 1 6 > 9 1
There's a simpler way to accomplish that: 5 6 7 (10&|@^) 3 2 $ 40 0 0 41 42 0 5 1 1 6 9 1 > Since Marshall's and Raul's solutions relied on stitching the > arguments together into a single table, I'm not sure if they could be > as easily generalized to heterogeneous ranks. They can be generalized rather easily, in my opinion, but before trying to generalize it's usually better to define what it is you are trying to accomplish. > One question: Is there a cleaner way to write (i.<:#$b)|:b > , in other words, to transpose the tail rank to the head > without affecting the head ranks? That seems clean enough, to me, for that operation. (How often do you work with high ranked arrays where you do not know how many dimensions the array has, where the dimensions are significant, and where you can't arrange the calculations to yield the dimension arrangement you prefer?) -- Raul ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm