Difference between revisions of "Slice"

Line 2: Line 2:
 
[[Category:Doc Status D]] <!-- For Lumina use, do not change -->
 
[[Category:Doc Status D]] <!-- For Lumina use, do not change -->
 
   
 
   
= Slice(A,I,n) =
+
== Slice(A, I, n) ==
  
Returns the ''«n»<sup>th</sup>'' slice of array «A» along index «I».
+
Returns the «n»th slice of array «A» along index «I».
  
The [[Slice]] function is so commonly used, as is its associational counterpart, the [[Subscript]] function, that a special shorthand notation is more often used in Analytica expressions.  <code>Slice(A,I,n)</code> can be written as [[Subscript-Slice Operator|A[@I=n]]].
+
The [[Slice]] function is so commonly used, as is its associational counterpart, the [[Subscript]] function, that a special shorthand notation is more often used in Analytica expressions.  <code>Slice(A, I, n)</code> can be written as [[Subscript-Slice Operator|A[@I = n]]].
  
= Slice(A,n) =
+
== Slice(A, n) ==
  
When «A» is one-dimensional, «I» can be omitted.  Use this syntax when you want to obtain the ''n<sup>th</sup>'' element of a list, but cannot name the index since it is implicit.
+
When «A» is one-dimensional, «I» can be omitted.  Use this syntax when you want to obtain the «n»th element of a list, but cannot name the index since it is implicit.
  
= Library =
+
== Library ==
  
 
Array functions
 
Array functions
  
= Examples =
+
== Examples ==
 +
:<code>Index I := [10, 20, 30, 40]</code>
 +
:<code>Index J := ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']</code>
 +
:<code>Index K := 1..3</code>
 +
:<code>Variable A := Table(J)(9, 2, 3, 4, 1, 9, 0, 3)</code>
 +
:<code>Variable B := I + K</code>
  
[[Index]] I := [10,20,30,40]
+
:<code>Slice(A, J, 5) &rarr; 1</code>
[[Index]] J := ['a','b','c','d','e','f','g','h']
+
:<code>Slice(A, J, 3..6) &rarr; [3, 4, 1, 9]</code>
[[Index]] K := 1..3
+
:<code>Slice(A, J, K) &rarr; Array(J, [9, 2, 3])</code>
Variable A := [[Table]](J)(9,2,3,4,1,9,0,3)
+
:<code>Slice(A, J, 8) &rarr; «null»  {with an out-of-range warning}</code>
Variable B := I+K
+
:<code>Slice(A, I, 3) &rarr; Array(J, [9, 2, 3, 4, 1, 9, 0, 3])</code>
  
[[Slice]](A,J,5) &rarr; 1
+
:<code>Slice(B, I, 3) &rarr; Array(K,[31, 32, 33])</code>
[[Slice]](A,J,3..6) &rarr; [3,4,1,9]
+
:<code>Slice(B, K, 3) &rarr; Array(I,[13, 23, 33, 43])</code>
[[Slice]](A,J,K) &rarr; [[Array]](J,[9,2,3])
 
[[Slice]](A,J,8) &rarr; «null»  {with an out-of-range warning}
 
[[Slice]](A,I,3) &rarr; [[Array]](J,[9,2,3,4,1,9,0,3])
 
  
[[Slice]](B,I,3) &rarr; [[Array]](K,[31,32,33])
+
:<code>Slice(4, J, 5) &rarr; 4</code>
[[Slice]](B,K,3) &rarr; [[Array]](I,[13,23,33,43])
 
 
 
[[Slice]](4,J,5) &rarr; 4
 
 
   
 
   
= See Also =
+
== See Also ==
 
 
 
* [[Subscript-Slice Operator]]
 
* [[Subscript-Slice Operator]]
 
* [[Subscript]]
 
* [[Subscript]]
 
<comments />
 

Revision as of 22:39, 11 January 2016


Slice(A, I, n)

Returns the «n»th slice of array «A» along index «I».

The Slice function is so commonly used, as is its associational counterpart, the Subscript function, that a special shorthand notation is more often used in Analytica expressions. Slice(A, I, n) can be written as A[@I = n].

Slice(A, n)

When «A» is one-dimensional, «I» can be omitted. Use this syntax when you want to obtain the «n»th element of a list, but cannot name the index since it is implicit.

Library

Array functions

Examples

Index I := [10, 20, 30, 40]
Index J := ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']
Index K := 1..3
Variable A := Table(J)(9, 2, 3, 4, 1, 9, 0, 3)
Variable B := I + K
Slice(A, J, 5) → 1
Slice(A, J, 3..6) → [3, 4, 1, 9]
Slice(A, J, K) → Array(J, [9, 2, 3])
Slice(A, J, 8) → «null» {with an out-of-range warning}
Slice(A, I, 3) → Array(J, [9, 2, 3, 4, 1, 9, 0, 3])
Slice(B, I, 3) → Array(K,[31, 32, 33])
Slice(B, K, 3) → Array(I,[13, 23, 33, 43])
Slice(4, J, 5) → 4

See Also

Comments


You are not allowed to post comments.