>> << Ndx Usr Pri Phr Dic Rel Voc !: wd Help Primer

# Open - monad >

The monad > (open) is the inverse of box. That is, it takes the contents out of a box. Applied to a noun that is already open it has no effect.

       > 23 5 7
    23 5 7

       a =. i.5
       a
    0 1 2 3 4

       < a
    +---------+
    ¦0 1 2 3 4¦
    +---------+

       > < a
    0 1 2 3 4

Look > up in the J Dictionary. The monad > has a rank of `0` so it applies to each atom in its argument. Each atom is opened, creating a partial result, that is then assembled with all the other partial results into the final result.

       a =. 1 2 3 ; 5 6 7
       a
    +-----------+
    ¦1 2 3¦5 6 7¦
    +-----------+

       > a
    1 2 3
    5 6 7

The assembly of the partial results is straightforward if they all have the same rank and shape. But with open the partial results could have very different ranks and shapes.

       a =. 1 ; 2 3 ; 4 5 6
       a
    +-----------+
    ¦1¦2 3¦4 5 6¦
    +-----------+

       > a
    1 0 0
    2 3 0
    4 5 6

Each atom is opened and the partial results are extended to fit into the result frame.

    > 1     	gives	1	(atom)
    > 2 3  	gives	2 3	(list)
    > 4 5 6	gives	4 5 6	(list)

The result frame has to have partial results that all have the same rank and shape. To do this, each partial result is extended to have the same rank as the rank of the highest rank result and a shape that is the maximum along any axis of all the partial results.

In the example above, the atom `1` is extended to a list and is padded with `0`'s to have a shape of `3`. The list`2 3` is padded with a `0` to have a shape of `3`. The `4 5 6` list is already OK. And the final result has a frame of `3` where each result cell is a list of 3 atoms.

What if the boxes contain characters?

       > 'abc' ; 'defg' ; 'hijkl'
    abc
    defg
    hijkl

The result is a `3` by `5` table. The character partial results are extended in a similar manner, but blanks are used as fill, rather than `0`. You cannot open a boxed list that contains both character and numeric data.

       > 1 2 3 ; 'asdf'
    ¦domain error
    ¦       >1 2 3;'asdf'

There is no way to put the numeric and character partial results together in the frame so there is a domain error.

>> << Ndx Usr Pri Phr Dic Rel Voc !: wd Help Primer