Back: 2.3.2 Selecting a range of indices Forward: 2.3.4 Selecting an arbitrary list of indices     FastBack: 2. Using Array Syntax Up: 2.3 Indexing FastForward: 3. Graphics         Top: Yorick: An Interpreted Language Contents: Table of Contents     About: About This Document

2.3.3 Nil index refers to an entire dimension

When you index a multi-dimensional array, very often you want to let one or more dimensions be “spectators”. In Yorick, you accomplish this by leaving the corresponding index blank:

 
x(3,)
x(,5:7)
y(,::-1,)
x(,)

In these examples, x is a 2-D array, and y is a 3-D array. The first example, x(3,), represents the 1-D array of all the elements of x with first index 3. The second represents a 2-D array of all of the elements of x whose second indices are 5, 6, or 7. In the third example, y(,::-1,) is the y array with the elements in reverse order along its middle index. The fourth expression, x(,), means the entire 2-D array x, unchanged.


Back: 2.3.2 Selecting a range of indices Forward: 2.3.4 Selecting an arbitrary list of indices     FastBack: 2. Using Array Syntax Up: 2.3 Indexing FastForward: 3. Graphics         Top: Yorick: An Interpreted Language Contents: Table of Contents     About: About This Document