If your vectors are really of different lengths, it makes sense to box
them.

In the case of the "table" you show here, what would its size be if one row
is length 2, another is length 4, and so on?  A table doesn't hold things of
different length because it's defined in terms of 2 dimensions: its rows,
which are all the same length, and its columns, which are all the same
length.

That's why J pads items if, for instance, you unbox your vector of vectors
to turn it into a table:
   >1 2;3 4 5 6;7 8 9
1 2 0 0
3 4 5 6
7 8 9 0

On Wed, Feb 24, 2010 at 11:54 PM, Alexander Mikhailov <[email protected]>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
>



-- 
Devon McCormick, CFA
^me^ at acm.
org is my
preferred e-mail
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to