Difference between revisions of "Implicit index"

(Created page with " Implicit index (also known as a ''null-index'') is an index that does not have a name. Because it has no name, there is no way to refer to it in expressions where i...")
 
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
[[Category: Arrays]]
  
[[Implicit index]] (also known as a ''null-index'') is an [[index]] that does not have a name.  
+
An [[Implicit index]] (also known as a ''null-index'') is an [[index]] that does not have a name, e.g. a list (a 1-dimensional array). It arises in rare cases in a Definition that contains a subexpression that generates a list of values.  Normally, when you define an Index variable as a list of values, it becomes an explicit index, for example:
  
Because it has no name, there is no way to refer to it in expressions where index parameters are expected. Most built-in Analytica functions can still be employed to operate over implicit indexes.  
+
:<code>Index Years := 2016 .. 2020</code>
  
To avoid ambiguity, Analytica does not allow more than one implicit index in an [[array]]. If you try to combine multiple arrays with implicit indexes, it will cause an [[Error Messages/40045|error]].
+
Or if you define a variable as an expression containing subexpression that generates a list, e.g.
  
When an implicit index reaches the top level of an expression, it is promoted to be a [[Self index]].
+
:<code>Variable Year_number := (1 .. 5) + 2015</code>
 +
:<code>Year_number -> [2016, 2017, 2018, 2019, 2020]</code>
  
Implicit indexes define [[Implicit Dimensions|implicit dimensions]], e.g. <code>(-3..3)</code> or <code>[-3, -2, -1, 0, 1, 2, 3]</code>.
+
The variable becomes  a [[Self index]], i.e. it acts as an Index with values 
  
Indexes that do have a name, are called ''explicit indexes'' and define ''explicit dimensions'', e.g.  <code>Index I := 1..10</code>
+
<code>Year_number -> [2016, 2017, 2018, 2019, 2020]</code>
 +
 
 +
<code>Year_number -> [2016, 2017, 2018, 2019, 2020]</code>
 +
 
 +
Because an implicit index has no name, you can't refer to it in [[expressions]] where index [[parameters]] are expected.
 +
 
 +
Most built-in Analytica [[functions]] work fine over implicit indexes, e.g. the [[Subset]] function:
 +
 
 +
:<code>Subset(1997..2008 > 2005) &rarr; [2006, 2007, 2008] </code>
 +
 
 +
vs
 +
 
 +
:<code>Index Years := 1997..2008</code>
 +
:<code>Subset(Years > 2005) &rarr; [2006, 2007, 2008] </code>
 +
 
 +
To avoid ambiguity, Analytica does not allow more than one implicit index in an [[array]]. It gives an error if you try to combine multiple arrays with implicit indexes.
 +
 
 +
When an implicit index reaches the top level of an expression, it is promoted to a [[Self index]].
 +
 
 +
Implicit indexes define [[Implicit Dimensions|implicit dimensions]], e.g. <code>(-3..3)</code> or <code>[-3, -2, -1, 0, 1, 2, 3]</code>. Indexes that do have a name, are called ''explicit indexes'' and define ''explicit dimensions'', e.g.  <code>Index I := 1..10</code>.
  
 
==See Also==
 
==See Also==

Latest revision as of 05:49, 27 February 2017


An Implicit index (also known as a null-index) is an index that does not have a name, e.g. a list (a 1-dimensional array). It arises in rare cases in a Definition that contains a subexpression that generates a list of values. Normally, when you define an Index variable as a list of values, it becomes an explicit index, for example:

Index Years := 2016 .. 2020

Or if you define a variable as an expression containing subexpression that generates a list, e.g.

Variable Year_number := (1 .. 5) + 2015
Year_number -> [2016, 2017, 2018, 2019, 2020]

The variable becomes a Self index, i.e. it acts as an Index with values

Year_number -> [2016, 2017, 2018, 2019, 2020]

Year_number -> [2016, 2017, 2018, 2019, 2020]

Because an implicit index has no name, you can't refer to it in expressions where index parameters are expected.

Most built-in Analytica functions work fine over implicit indexes, e.g. the Subset function:

Subset(1997..2008 > 2005) → [2006, 2007, 2008]

vs

Index Years := 1997..2008
Subset(Years > 2005) → [2006, 2007, 2008]

To avoid ambiguity, Analytica does not allow more than one implicit index in an array. It gives an error if you try to combine multiple arrays with implicit indexes.

When an implicit index reaches the top level of an expression, it is promoted to a Self index.

Implicit indexes define implicit dimensions, e.g. (-3..3) or [-3, -2, -1, 0, 1, 2, 3]. Indexes that do have a name, are called explicit indexes and define explicit dimensions, e.g. Index I := 1..10.

See Also

Comments


You are not allowed to post comments.