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

# Each

Frequently with boxed data it is useful to be able to do something to the contents of each of the boxes. This is so useful that the standard profile defines an adverb called each that does exactly this. The definition of each involves a little more than you have covered so far, but don't worry about the details, just use it.

The adverb each takes a verb as its left argument. The derived verb is applied to the contents of the boxes of its arguments.

       a =. 10 12 13 ; 2 3 ; 4 5 6 8 3
       a
    +----------------------+
    ¦10 12 13¦2 3¦4 5 6 8 3¦
    +----------------------+

       +/ each a	NB. sum over each
    +-------+
    ¦35¦5¦26¦
    +-------+

       */ each a	NB. times over each
    +-----------+
    ¦1560¦6¦2880¦
    +-----------+

       |. each a	NB. reverse each
    +----------------------+
    ¦13 12 10¦3 2¦3 8 6 5 4¦
    +----------------------+

       >./ each a	NB. max over each
    +------+
    ¦13¦3¦8¦
    +------+

The previous examples all used the derived verb monadically. The following use the derived verb dyadically.

       23 , each a		NB. append each
    +-------------------------------+
    ¦23 10 12 13¦23 2 3¦23 4 5 6 8 3¦
    +-------------------------------+

       5 < each a
    +-------------------+
    ¦1 1 1¦0 0¦0 0 1 1 0¦
    +-------------------+

       1 |. each a
    +----------------------+
    ¦12 13 10¦3 2¦5 6 8 3 4¦
    +----------------------+

Did you catch the new verb `|.` (reverse or rotate) that slipped in above? Did you look it up in the J Dictionary?

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