;(< every i. 2 5);<<every i. 3 5 +--+--+--+--+--+ |0 |1 |2 |3 |4 | +--+--+--+--+--+ |5 |6 |7 |8 |9 | +--+--+--+--+--+ |0 |1 |2 |3 |4 | +--+--+--+--+--+ |5 |6 |7 |8 |9 | +--+--+--+--+--+ |10|11|12|13|14| +--+--+--+--+--+
On Mon, Feb 23, 2009 at 10:47 PM, Alex Rufon <[email protected]>wrote: > Here is the scenario. I have the following data: > (< every i. 2 5);<<every i. 3 5 > +-----------+----------------+ > |+-+-+-+-+-+|+--+--+--+--+--+| > ||0|1|2|3|4|||0 |1 |2 |3 |4 || > |+-+-+-+-+-+|+--+--+--+--+--+| > ||5|6|7|8|9|||5 |6 |7 |8 |9 || > |+-+-+-+-+-+|+--+--+--+--+--+| > | ||10|11|12|13|14|| > | |+--+--+--+--+--+| > +-----------+----------------+ > > What I want to do is to get the data this way: > +--+--+--+--+--+ > |0 |1 |2 |3 |4 | > +--+--+--+--+--+ > |5 |6 |7 |8 |9 | > +--+--+--+--+--+ > |0 |1 |2 |3 |4 | > +--+--+--+--+--+ > |5 |6 |7 |8 |9 | > +--+--+--+--+--+ > |10|11|12|13|14| > +--+--+--+--+--+ > > But if I try just unboxing the data, I would not get what I want (I even > tried using "each" and "every" to no avail): > $ >(< every i. 2 5);<<every i. 3 5 > 2 3 5 > > I could get the result by doing this: > foo=: 3 : 0 > data=. (0,(#|: 0 pick y)) $ <'' > for_xyz. y do. > data=. data, tomatrix 0 pick xyz > end. > data > ) > > foo (< every i. 2 5);<<every i. 3 5 > +--+--+--+--+--+ > |0 |1 |2 |3 |4 | > +--+--+--+--+--+ > |5 |6 |7 |8 |9 | > +--+--+--+--+--+ > |0 |1 |2 |3 |4 | > +--+--+--+--+--+ > |5 |6 |7 |8 |9 | > +--+--+--+--+--+ > |10|11|12|13|14| > +--+--+--+--+--+ > > So how do I get what I want without resorting to a for_ loop? > > Thanks. :) > > r/Alex > > > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
