Hi Alex, Boxing is essential particularly to what you're describing.
For implicit boxing and unboxing, I would like to suggest the use of the following verbs: cutopen each every pick These verbs are actually part of the standard library thats loaded automatically when your J profile is loaded. My script is in /Applications/j602/system/main/stdlib.ijs [data=. 1 2; 3 4 5 6;7 8 9 +---+-------+-----+ |1 2|3 4 5 6|7 8 9| +---+-------+-----+ >": each data 1 2 3 4 5 6 7 8 9 cutopen >": each data +-------+-------+-------+ |1 2 |3 4 5 6|7 8 9 | +-------+-------+-------+ [work1=. deb each cutopen >": each data +---+-------+-----+ |1 2|3 4 5 6|7 8 9| +---+-------+-----+ datatype each work1 +-------+-------+-------+ |literal|literal|literal| +-------+-------+-------+ ". each work1 +---+-------+-----+ |1 2|3 4 5 6|7 8 9| +---+-------+-----+ ". every work1 1 2 0 0 3 4 5 6 7 8 9 0 2 1 0 pick data 7 8 9 0 3 4 5 6 1 2 0 0 1 pick data 3 4 5 6 Oh, I almost forgot, you can also use the for_xyz. format for doing loops. r/Alex On Feb 25, 2010, at 12:54 PM, Alexander Mikhailov wrote: > > I'm a novice in J, and when trying to write programs, I'm very often use > boxes to store arrays of different length together, like this - > > +---+-------+-----+ > |1 2|3 4 5 6|7 8 9| > +---+-------+-----+ > > Those arrays are usually results of previous steps of computations, and > semantically the rows are similar, but I can't store them in a table, like > this - > > 1 2 > 3 4 5 6 > 7 8 9 > > because J requires all items to have the same shape. So, I end up doing > boxing and unboxing. > > As far as I know, the reason to have boxes in J was to allow to have elements > of different "kinds" - like ranks, or lengths, or types - in the same array. > Is it reasonable to have boxing/unboxing operations to be done implicitly in > the case like above - or am I missing other important uses of boxes? > > Alexander > > > > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
