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

www.microapl.co.uk

¨ 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 | APL Home ]