home
manual
quick ref.
packages
index
keywords
examples
PREV UP NEXT Yorick

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.

LLNL Disclaimers