Difference between revisions of "SubIndex"
m (adding doc status category stub page) |
|||
Line 2: | Line 2: | ||
[[Category:Doc Status D]] <!-- For Lumina use, do not change --> | [[Category:Doc Status D]] <!-- For Lumina use, do not change --> | ||
− | = | + | = SubIndex(A,u,I) = |
− | SubIndex(A, | + | Returns the value from index «I» at which the value «u» is found in array «A». If «u» does not occur in «A», returns [[Null]]. If «u» occurs more than once in «A», returns the value in «I» corresponding to the last occurrence of «u». |
+ | |||
+ | = Library = | ||
+ | |||
+ | Array Functions | ||
+ | |||
+ | = Array Abstraction = | ||
+ | |||
+ | When «A» has more than one dimension, or «u» is an array, [[SubIndex]] array abstracts according to the standard rules of [[Array Abstraction|array abstraction]]. For example, when «A» contains an index other than I, [[SubIndex]] is applied to each slice of that index, returning the position of «u» in the corresponding slice. When «u» contains an array of values, the position of each of those values in «A» is returned. | ||
+ | |||
+ | = Examples = | ||
+ | |||
+ | Let: | ||
+ | {| border=0 | ||
+ | | | ||
+ | {| border=1 | ||
+ | ! I → !! 'a' !! 'b' !! 'c' !! 'd' !! 'e' !! 'f' | ||
+ | |- | ||
+ | ! A → | ||
+ | | 4 || 3 || 2 || 5 || 3 || 1 | ||
+ | |} | ||
+ | | || | ||
+ | {| border="1" | ||
+ | ! colspan=2 rowspan=2 | B | ||
+ | ! colspan=6 | I | ||
+ | |- | ||
+ | ! 'a' !! 'b' !! 'c' !! 'd' !! 'e' !! 'f' | ||
+ | |- | ||
+ | !rowspan=2 | J | ||
+ | ! 1 | ||
+ | | 3 || 5 || 2 || 4 || 5 || 3 | ||
+ | |- | ||
+ | ! 2 | ||
+ | | 2 || 1 || 5 || 2 || 3 || 4 | ||
+ | |} | ||
+ | | || | ||
+ | {| border=1 | ||
+ | ! K → !! 1 !! 2 !! 3 !! 4 !! 5 | ||
+ | |- | ||
+ | ! C → | ||
+ | | 4 || 2 || 5 || 1 || 3 | ||
+ | |} | ||
+ | |} | ||
+ | |||
+ | Then: | ||
+ | :[[SubIndex]](A,2,I) → 'c' | ||
+ | :[[SubIndex]](A,3,I) → 'e' | ||
+ | :[[SubIndex]](A,6,I) → [[«null»]] | ||
+ | :[[SubIndex]](A,1..5,I) → ['f', 'c', 'e', 'a', 'd'] | ||
+ | {| border=0 | ||
+ | | | ||
+ | | [[SubIndex]](A,C,I) → || | ||
+ | {| border=1 | ||
+ | ! K → !! 1 !! 2 !! 3 !! 4 !! 5 | ||
+ | |- | ||
+ | ! | ||
+ | | 'a' || 'c' || 'd' || 'f' || 'e' | ||
+ | |} | ||
+ | |} | ||
+ | |||
+ | |||
+ | {| border=0 | ||
+ | | | ||
+ | | [[SubIndex]](B,2,I) → || | ||
+ | {| border=1 | ||
+ | ! J → !! 1 !! 2 | ||
+ | |- | ||
+ | ! | ||
+ | | 'c' || 'd' | ||
+ | |} | ||
+ | |} | ||
+ | |||
+ | {| border=0 | ||
+ | | | ||
+ | | [[SubIndex]](B,C,I) → || | ||
+ | {| border="1" | ||
+ | ! colspan=2 rowspan=2 | B | ||
+ | ! colspan=6 | K | ||
+ | |- | ||
+ | ! 1 !! 2 !! 3 !! 4 !! 5 | ||
+ | |- | ||
+ | !rowspan=2 | J | ||
+ | ! 1 | ||
+ | | 'd' || 'c' || 'e' || [[«null»]] || 'f' | ||
+ | |- | ||
+ | ! 2 | ||
+ | | 'f' || 'd' || 'c' || 'd' || 'e' | ||
+ | |} | ||
+ | |||
+ | |} | ||
= See Also = | = See Also = | ||
* [[PositionInIndex]] | * [[PositionInIndex]] |
Revision as of 17:52, 31 December 2008
SubIndex(A,u,I)
Returns the value from index «I» at which the value «u» is found in array «A». If «u» does not occur in «A», returns Null. If «u» occurs more than once in «A», returns the value in «I» corresponding to the last occurrence of «u».
Library
Array Functions
Array Abstraction
When «A» has more than one dimension, or «u» is an array, SubIndex array abstracts according to the standard rules of array abstraction. For example, when «A» contains an index other than I, SubIndex is applied to each slice of that index, returning the position of «u» in the corresponding slice. When «u» contains an array of values, the position of each of those values in «A» is returned.
Examples
Let:
|
|
|
Then:
- SubIndex(A,2,I) → 'c'
- SubIndex(A,3,I) → 'e'
- SubIndex(A,6,I) → «null»
- SubIndex(A,1..5,I) → ['f', 'c', 'e', 'a', 'd']
SubIndex(A,C,I) → |
|
SubIndex(B,2,I) → |
|
SubIndex(B,C,I) → |
|
See Also
Comments
Enable comment auto-refresher