¨ Each


One-argument form

The ¨ ('each') operator applies its operand to each element of its argument. In the case of a scalar operand, or a scalar function, each has no effect.

             DAYS„'MONDAY' 'TUESDAY'
             ½¨DAYS
       6 7
             DATA„(2 2½¼4) (¼10) 97.3 (3 4½'K')
             ½DATA                   (Length 4 nested vector)
       4
             ½¨DATA                  (Shape of each element, note empty vector
          2 2  10    3 4              shape for element 3, the scalar)
             ½½¨DATA                 (4 shapes returned)
       4
             ½¨½¨DATA                (The shape of each of the shapes - the
          2  1  0 2                   ranks - of each element)

Two-argument form

The two-argument form of each applies is left argument and its operand to each element of its right argument. Again, for empty left or right arguments, a fill function is applied.

             (1 2 3),¨4 5 6          (Joining successive pairs of elements in
        1 4  2 5  3 6                 the left and right arguments)
             2 3†¨'MONDAY' 'TUESDAY' (2† of first element of right argument
        MO TUE                        3† of the second)
             2†¨'MONDAY' 'TUESDAY'   (Scalar extension results in 2† of each
        MO TU                         element of the right argument)
             2 3½¨1 2                (2½ of first element, 3½ of second)
          1 1  2 2 2
             4 5½¨'THE' 'CAT'
       THET CATCA

Topic: APLX Help : Help on APL language : APL Primitives : ¨ Each
[ Previous | Next | Contents | Index ]