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

www.microapl.co.uk

Index of


Two-argument form  See also one-argument form Index generator

finds whether the items in the right argument occur in the left argument (which must be a vector) and if so in what positions. For each element in the right argument a number is returned showing its position in the left argument. If an element is not found in the left argument (or if the arguments are of different types), a number one greater than the position of the last element in the left argument is returned. The shape of the result is the same as that of the left argument.

The result of dyadic is influenced by ⎕IO, which will control whether the index positions start at 0 or 1 - for more details see the entry for ⎕IO. The comparisons done by this operation are affected by ⎕CT, the comparison tolerance value.

             2 5 9 14 20 ⍳ 9
       3                              (9 is in position 3)
             2 5 9 14 20 ⍳ 12         (12 isn't in the left argument, so a
       6                               number 1 greater than the number of
                                       elements on the left results)
             'GORSUCH' ⍳ 'S'
       4                              (S occurs in position 4)
             'ABCDEFGHIJKLMNOPQRSTUVWXYZ' ⍳ 'CARP'
       3 1 18 16                      (The characters 'CARP' are in positions
                                       3 1 18 and 16)
              'ABCDEFGHIJKLMNOPQRSTUVWXYZ' ⍳ 'PORK PIE'
       16 15 18 11 27 16 9 5          (The 27 in the result indicates
                                       characters not found in the 26-character
                                       left argument. In this case the 'space'
                                       character.)
             DAYS←'MON' 'TUES' 'WED'
             ⍴DAYS
       3                              (DAYS is a 3 element vector)
             DAYS ⍳ 'MON' 'THURS'     ('MON' found in first position, 'THURS'
       1 4                             is not found)

See (Match) for a discussion of the criteria which determine whether two elements are considered the same.


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