Home Manual Packages Global Index Keywords Quick Reference |
> ## 2.3 Indexing Yorick has a bewildering variety of different ways to refer to individual array elements or subsets of array elements. In order to master the language, you must learn to use them all. Nearly all of the examples later in this manual use one or more of these indexing techniques, so trust me to show you how to use them later: A scalar integer index refers to a specific array element. In a multi-dimensional array, this "element" is itself an array -- the specified row, column, or hyperplane. An index which is nil or omitted refers to the entire range of the corresponding array dimension. An index range of the form `start:stop` or `start:stop:step` refers to an evenly spaced subset of the corresponding array dimension. An array of integers refers to an arbitrary subset, possibly including repeated values, of the corresponding array dimension. The special symbol `-`, or `-:start:stop`, is the pseudo-index. It inserts an index in the result which was not present in the array being indexed. Although this sounds recondite, the pseudo-index is often necessary in order to make two arrays conformable for a binary operation. The special symbol `..` or `*` is a rubber-index. A rubber-index stands for zero or more dimensions of the array being indexed. This syntax allows you to specify a value for the final index of an array, even when you don't know how many dimensions the array has. The `..` version leaves the original dimension count intact; the `*` version collapses all dimensions into a single long dimension in the result. The special symbol `+` marks an index for matrix multiplication. Many statistical functions, such as `sum`, `avg`, and `max` can be applied along a specific dimension of an array. These reduce the rank of the resulting array, just like a scalar integer index value. Several finite difference functions, such as `zcen` (zone center) and `cum` (cumulative sums) can be applied along a specific array dimension. You can use these to construct numerical analogues to the operations of differential and integral calculus.
> 2.3.1 Scalar indices and array order |  |
> 2.3.2 Selecting a range of indices |  |
> 2.3.3 Nil index refers to an entire dimension |  |
> 2.3.4 Selecting an arbitrary list of indices |  |
> 2.3.5 Creating a pseudo-index |  |
> 2.3.6 Numbering a dimension from its last element |  |
> 2.3.7 Using a rubber index |  |
> 2.3.8 Marking an index for matrix multiplication |  |
> 2.3.9 Rank reducing (statistical) range functions |  |
> 2.3.10 Rank preserving (finite difference) range functions |  |