Difference between revisions of "IndexesOf"

 
(5 intermediate revisions by 2 users not shown)
Line 3: Line 3:
 
[[Category:Meta-Inference Functions]]
 
[[Category:Meta-Inference Functions]]
  
 +
== IndexesOf(a'', except...'') ==
 +
Returns a list of [[handle]]s to the indexes of array «a». It is different from [[IndexNames]](a), which returns the identifiers of the indexes as text values instead of handles. 
 +
 +
If «X» has an [[implicit index]] (an index without a name), the first element of the output list is [[null]], rather than a handle.
  
== IndexesOf(a) ==
+
If the array has more than one [[Local Indexes|local index]] with the same identifier, you can use [[IndexesOf]](a) to identify each index safely because each handle unambiguously refers to the corresponding index, where [[IndexNames]](a) would return the identifiers as identical and therefore ambiguous text values.
Returns a list of [[handle]]s to the indexes of array «a». It is different from [[IndexNames]](a), which returns the identifiers of the indexes as text values instead of handles.
 
  
Sometimes an array has more than one [[Local Indexes|local index]] with the same identifier. In this case, you can use [[IndexesOf]](a) to identify each index safely because each handle unambiguously refers to the corresponding index, where [[IndexNames]](a) would return the identifiers as identical and therefore ambiguous text values.
+
The optional «except» parameter excludes any of the indexes that are listed.
  
 
[[Syntax]]:  
 
[[Syntax]]:  
Line 13: Line 16:
  
 
== Example ==
 
== Example ==
:<code>IndexNames(Car_prices) &rarr; [Car_types, Year]</code>
+
:<code>IndexesOf(Car_prices) &rarr; [Car_types, Year]</code>
 +
 
 +
:<code>IndexesOf(Car_prices, except: Car_types) &rarr; [Year]</code>
 +
 
 +
Find the maximum in <code>A</code> over all indexes:
 +
:<code>[[Max]]( A, ...[[IndexesOf]](A) )</code>
 +
 
 +
Sum over all indexes of <code>x</code> except <code>J</code> and <code>K</code>:
 +
:<code>[[Sum]]( x, ...[[IndexesOf]](x, except: J,K) )</code>
 +
 
 +
== History ==
 +
* The «except» parameter was introduced in [[Analytica 5.2]].
  
 
== See Also ==  
 
== See Also ==  
Line 19: Line 33:
 
* [[Handle Functions]]
 
* [[Handle Functions]]
 
* [[IndexNames]]
 
* [[IndexNames]]
 +
* [[Repeated parameter forwarding]]

Latest revision as of 00:06, 19 November 2024


IndexesOf(a, except...)

Returns a list of handles to the indexes of array «a». It is different from IndexNames(a), which returns the identifiers of the indexes as text values instead of handles.

If «X» has an implicit index (an index without a name), the first element of the output list is null, rather than a handle.

If the array has more than one local index with the same identifier, you can use IndexesOf(a) to identify each index safely because each handle unambiguously refers to the corresponding index, where IndexNames(a) would return the identifiers as identical and therefore ambiguous text values.

The optional «except» parameter excludes any of the indexes that are listed.

Syntax:

IndexesOf(a: Array)

Example

IndexesOf(Car_prices) → [Car_types, Year]
IndexesOf(Car_prices, except: Car_types) → [Year]

Find the maximum in A over all indexes:

Max( A, ...IndexesOf(A) )

Sum over all indexes of x except J and K:

Sum( x, ...IndexesOf(x, except: J,K) )

History

See Also

Comments


You are not allowed to post comments.