Indexing: Difference between revisions

From NARS2000
Jump to navigationJump to search
No edit summary
No edit summary
Line 56: Line 56:
</tr>
</tr>
<tr>
<tr>
   <td>That is, if the largest allowed index value is <apll>N</apll>, then the previous allowable range of values was <apll>⎕IO</apll> to <apll>N</apll>, inclusive.  Now, the allowable range of values is <apll>1 ¯1[1]-N</apll> to <apll>N</apll>, inclusive.  For example, <apll>A</apll>, <apll>A[⍳⍴A]</apll>, and <apll>A[⍳-⍴A]</apll> are all identical for any array <apll>A</apll> in either origin.</td>
   <td>That is, if the largest allowed index value is <apll>N</apll>, then the previous allowable range of values was <apll>⎕IO</apll> to <apll>N</apll>, inclusive.  Now, the allowable range of values is <apll>1 ¯1[1]-N</apll> to <apll>N</apll>, inclusive.  For example, <apll>A</apll>, <apll>A[⍳⍴A]</apll>, <apll>A[⍳-⍴A]</apll>, and even <apll>A[⍳¯1 1[?(⍴⍴A)⍴2]×⍴A]</apll> are all identical for any array <apll>A</apll> in either origin.</td>
</tr>
</tr>
<tr>
<tr>

Revision as of 21:47, 14 April 2008

Z←R[L], R[L]←A, and R[L]f←A are all extended to allow both Reach and Scatter indexing.
L is a nested array of integer scalars and/or vectors, suitable for indexing R.
R is an arbitrary array.
A is an arbitrary array.
Reach Indexing: If L⊃R is valid, it is equivalent to ⊃R[⊂L]
Scatter Indexing: If L⌷R is valid, it is equivalent to R[⊃∘.,/L]
Both Reach and Scatter indexing may appear together within a single instance of R[L], R[L]←A, and R[L]f←A


For example, in origin-1

      V←'123'(⊂4 5)
      V[1 (2 ⍬ 1)]
 123 4


Z←R[L], R[L]←A, R[L]f←A, L⌷R, and L⊃R are all extended to allow negative index values.
L is a nested array of integer scalars and/or vectors, suitable for indexing R.
That is, if the largest allowed index value is N, then the previous allowable range of values was ⎕IO to N, inclusive. Now, the allowable range of values is 1 ¯1[1]-N to N, inclusive. For example, A, A[⍳⍴A], A[⍳-⍴A], and even A[⍳¯1 1[?(⍴⍴A)⍴2]×⍴A] are all identical for any array A in either origin.
R is an arbitrary array.
A is an arbitrary array.


For example, in origin-1

      V←'123'(⊂4 5)
      V[¯1 (0 ⍬ ¯1)]
 123 4