Error Messages/40045

Error Text

Trying to combine two arrays with implicit indexes. An array can contain only one implicit index. One cure might be to define at least one of these as an explicit index.


The parameters in the call to Function someFunc contain two (or more) implicit indexes that must be iterated over. The result would contain two implicit dimensions, which is not allowed. One remedy would be to make one of these an explicit index.


Each dimension of a multi-dimensional array in Analytica is associated with an index. The one exception to this rule is that an array can have one implicit dimension, but only one. This error message occurs when you perform an operation would result in two or more implicit dimensions.

The constraint of allowing at most one implicit dimension in an array ensures that we can always unambiguously specify which dimension we want to operate over whenever we perform an array operation. For example, if we want to find the maximum value along the I index, we can write Max(A, I). Since an implicit dimension has no name (because it is implicit), we can't name it in this fashion; however, in most cases, Analytica allows you to omit the index, such that if the array contains an implicit dimension, you want to operate over that dimension. If an array were to contain multiple implicit dimensions, it would be impossible to unambiguously identify the dimension of interest; hence, more than one implicit dimension results in this error.

An implicit dimension gets promoted to become a self-index if it still exists in the final result for a variable (after the promotion, the dimension is no longer implicit since at that point, it has a name). Again, if there were two implicit dimensions, it would be ambiguos as to which one should be promoted.


Usually, you'll see this because you are combining two arrays, each of which already has its own explicit index. These are treated as two separate dimensions, even if they are the same length:

[1, 2, 3]*[4, 5, 6] → Error: Trying to combine two arrays with implicit indexes.

The problem can arise when you attempt to array abstract over a function that returns a list, since you'll have a list result for each case. Functions in this class include SplitText, Sequence, Subset, Unique, SortIndex. For example:

SplitText(["1, 2, 3", "4, 5", "8", "9, 10, 11, 12"], ',') → Error: Trying to combine two arrays with implicit indexes.

The error can also occur when you try to pass an unindexed list to a parameter of a function that allows a variable number of repeated parameters. These parameters are qualified with the repeated or ellipsis ('...') qualifiers. For example:

Function F(x: repeated) := Sum(x)
Variable Va1 := F(1, 2, 3..9)

What happens here is that the implicit dimension is used to index the variable number of parameters, so it is no longer available as an index within each parameter. So in this example, the third parameter has the implicit index, so that the value of x passed into the function has two implicit dimensions, thus causing this error.


The remedy to this problem is to replace one of the implicit dimensions with an explicit dimension.

Index X1 := [1, 2, 3] Do X1*[4, 5, 6] →
X1 (implicit dimension)
1 4 5 6
2 8 10 12
3 12 15 18

In the case where you are array abstracting over a function that returns a list result, there is not a single simple answer to what the appropriate remedy is. Theoretically, the result of such an operation could be a non-rectangular array, which is not allowed in Analytica. To see this, consider Sequence(1, [2, 4, 6]) which would produce sequences [1, 2], [1, 2, 3, 4], and [1, 2, 3, 4, 5, 6]. If these could be combined in to an array, each row of the array would have a different number of columns. So, in such a situation, you need to determine what the best way is in your case to deal with the non-rectangularity.

One approach is to introduce an explicit dimension with enough elements to handle the longest case you care about. You would then pad all unused cells with Null values. In the Sequence example, that looks like this:

Index D := 1..6;
For v = [2, 4, 6] Do (
IgnoreWarnings(Array(D, Sequence(1, v)))) →
.D ▶
implicit dimension 1 2 3 4 5 6
2 1 2 «null» «null» «null» «null»
4 1 2 3 4 «null» «null»
6 1 2 3 4 5 6

Several built-in functions (e.g., SplitText, Subset) have optional parameters to do this mapping of the implicit index in the result to an existing index for you. For example:

Index Index D := 1..3;
SplitText(["1, 2, 3, 4", "5", "6, 7", "8, 9, 10"], ",", resultindex: D) →
.D ▶
implicit dimension 1 2 3
"1, 2, 3, 4" "1" "2" "3, 4"
"5" "5" «null» «null»
"6, 7" "6" "7" «null»
"8,9,10" "8" "9" "10"

A different approach for dealing with non-rectangularity is to keep each list result inside a reference, so the implicit dimensions don't combine:

For v := [1, 2, 3] do \(v * [4, 5, 6]) →
\([4, 5, 6])
\([8, 10, 12])
\([12, 15, 18])

See Also


You are not allowed to post comments.