O'Reilly logo

Rexx Programmer's Reference by Howard Fosdick

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 4. Arrays

Overview

Every programming language provides for arrays. Sometimes they are referred to as tables. This basic data structure allows you to build lists of "like elements," which can be stored, searched, sorted, and manipulated by other basic programming operations.

Rexx's implementation of arrays is powerful but easy to use. Arrays can be of any dimensionality. They can be a one-dimensional list, where all elements in the array are of the same kind. They can be of two dimensions, where there exist pairs of entries. In this case, elements are manipulated by two subscripts (such as I and J). Or, arrays can be of as many dimensions as you like. While Rexx implementations vary, the usual constraint on the size and dimensionality of array is memory. This contrasts with other programming languages that have specific, language-related limitations on array size.

Rexx arrays may be sparse. That is, not every array position must have a value or even be initialized. There can be empty array positions, or slots, between those that do contain data elements. Or arrays can be dense, in which consecutive array slots all contain data elements. Figure 4-1 below pictorially shows the difference between sparse and dense arrays. Dense arrays are also sometimes called nonsparse arrays.

Arrays may be initialized by a single assignment statement. But just like other variables, arrays are defined by their first use. You do not have to predefine or preallocate them. Nor must you declare a maximum ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required