Google

Yorick Reference Card

yorick banner

Home

Manual

Packages

Global Index

Keywords

Quick Reference

Yorick Language Reference

Indexing Arrays

x(index1, index2, ..., indexN ) is a subarray of the array x

Each index corresponds to one dimension of the x array, called the ID in this section (the two exceptions are noted below). The index1 varies fastest, index2 next fastest, and so on. By default, Yorick indices are 1-origin. An indexI may specify multiple index values, in which case the result array will have one or more dimensions which correspond to the ID of x. Possibilities for the indexI are:

scalar index
Select one index. No result dimension will correspond to ID.
nil ([] or omitted)
One result dimension will match the ID.
index range start:stop or start:stop:step
Select start, start+step, start+2*step, etc. One result dimension of length 1+(stop-start)/step and origin 1 will correspond to ID. The default step is 1; it may be negative. In particular, ::-1 reverses the order of ID.
index list
Select an arbitrary list of indices - the index list can be any array of integers. The dimensions of the index list will replace the ID in the result.
pseudo-index -
Insert a unit length dimension in the result which was not present in the original array x. There is no ID for a - index.
rubber-index .. or *
The ID may be zero or more dimensions of x, forcing it indexN to be the final actual index of x. A .. preserves the actual indices, * collapses them to a single index.
range function ifunc or ifunc:range
Apply a range function to all or a subset of the ID; the other dimensions are ``spectators''; multiple ifunc are performed successively from left to right. Index Range Functions gives a complete list of range functions.

Function results and expressions may be indexed directly, e.g.:

f(a,b,c)(index1,index2)   or   (2*x+1)(index1,index2,index3)

If the left hand operand of the = operator is an indexed array, the right hand side is converted to the type of the left, and the specified array elements are replaced. Do not confuse this with the redefinition operation var =:

x(index1, index2, ..., indexN )= expr       assign to a subarray of x