Error Messages/40021

< Error Messages
Revision as of 22:02, 8 March 2016 by Bbecane (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Error message

One or both parameters to the sequence (dot-dot) operator, m..n, are not scalars.

Cause

You can define a list of consecutive numbers easily using the syntax such as:

10..20

This would define the list [10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], equivalent also to Sequence(10, 20).

Because it generates a list, this operator (like the function Sequence) is not array-abstractable. It can only be used when the start value and ending value parameters are scalars. If a dimension gets introduced into one or both of the end-points, an error results.

To understand this limitation, consider the following example, where two indexes are defined:

Index I := 10..20
Index J := 1..I

The definition of I is fine, but the termination value for J is an array, implying an array of lists:

1..10
1..11
1..12
...
1..20

If this were allowed, this would be a non-rectangular array. First, it doesn't make sense to define an index as multi-dimensional array - J should be defined as a list, and second, Analytica arrays must be rectangular. Because of that, such a use of a sequence operator is not allowed.

Remedies

If you are seriously trying to make this work, you probably have a situation that is naturally non-rectangular. To capture non-rectangularity, there are a couple approaches.

  1. Use one dimension that is long enough to hold every case. Pad arrays with Null values for slices with only a few cases along other dimensions. The data structure is thus rectangular, keeping Analytica happy, while the cells with non-null values is arbitrarily non-rectangular.
  2. Use References to create tree-structured data structures.
  3. Use a relational representation (see MdTable and MdArrayToTable) rather than a multi-dimensional array data structure. A relational expression lists all valid cells along one index (the row dimension), and for each row, the coordinates of that row are described in columns along another dimension, along with the actual value for that row.

Each of these alternatives comes with its own advantages and drawbacks.

See Also

Comments


You are not allowed to post comments.