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

www.microapl.co.uk

Index generator


One-argument form  See also two-argument form Index of

generates a series of integers which start at the index origin (⎕IO) and whose length is specified by the right argument which must be 0 or a positive integer scalar. The examples below assume the default index origin of 1 (see ⎕IO for more details). The argument to must be a simple numeric scalar or one-element vector.

             ⎕IO                     (Default setting of ⎕IO)
       1

To generate the series from 1 to 10:

             ⍳ 10
       1 2 3 4 5 6 7 8 9 10

To generate the series 1 to 5 to be used in selecting the first five elements from a vector (see separate entry for [ ]):

             PRICE←29 4 61 5 88 2 18 90 3 201 12 53 27 80
             PRICE[⍳ 5]
       29 4 61 5 88

To generate a vector of five elements containing the series 1, 1 2, and so on, use the ¨ ('each') operator.

             ⍳¨⍳5
        1  1 2  1 2 3  1 2 3 4  1 2 3 4 5

A common mechanism to generate an empty vector is:

             ⍳0
                                     (No display)

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