Indexing: Difference between revisions
From NARS2000
Jump to navigationJump to search
mNo edit summary |
Sudleyplace (talk | contribs) No edit summary |
||
Line 50: | Line 50: | ||
<p>For example, in origin-1</p> | <p>For example, in origin-1</p> | ||
<apll> | <apll><pre> | ||
V←'123'(⊂4 5) | |||
V[1 (2 ⍬ 1)] | |||
123 4 | |||
M←2 2⍴(10 20) (30 40 'abc') 50 60 | |||
M[(1 1)((1 2) 3)] | |||
10 20 abc</pre></apll> | |||
<table border="1" cellpadding="5" cellspacing="0" rules="none" summary=""> | <table border="1" cellpadding="5" cellspacing="0" rules="none" summary=""> | ||
<tr> | <tr> | ||
Line 85: | Line 83: | ||
</tr> | </tr> | ||
<tr> | <tr> | ||
<td>These functions are sensitive to <apll>⎕IO</apll>.</td> | <td>These functions are sensitive to <apll>⎕IO</apll>. Negative indexing is available only when the first element of <apll>⎕FEATURE</apll> is set to <apll>1</apll>.</td> | ||
</tr> | </tr> | ||
</table> | </table> | ||
Line 91: | Line 89: | ||
<p>For example, in origin-1</p> | <p>For example, in origin-1</p> | ||
<apll> | <apll><pre> | ||
⎕FEATURE[1]←1 | |||
V←'123'(⊂4 5) | |||
V[¯1 (0 ⍬ ¯1)] | |||
123 4</pre></apll> |
Revision as of 17:41, 15 April 2018
|
||||||||
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. | ||||||||
| ||||||||
Both Reach and Scatter indexing may appear together within a single instance of R[L], R[L]←A, and R[L]f←A | ||||||||
These functions are sensitive to ⎕IO. |
For example, in origin-1
V←'123'(⊂4 5) V[1 (2 ⍬ 1)] 123 4 M←2 2⍴(10 20) (30 40 'abc') 50 60 M[(1 1)((1 2) 3)] 10 20 abc
|
||||
For all but transpose, L is a nested array of integer scalars and/or vectors, suitable for indexing R; for transpose, L is an integer scalar or vector of integers, suitable for transposing R. | ||||
That is, if the largest allowed value for L 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. Also, A, (⍳⍴⍴A)⍉A, and (⍳-⍴⍴A)⍉A are all identical for any array A in either origin. |
||||
R is an arbitrary array. | ||||
A is an arbitrary array. | ||||
These functions are sensitive to ⎕IO. Negative indexing is available only when the first element of ⎕FEATURE is set to 1. |
For example, in origin-1
⎕FEATURE[1]←1 V←'123'(⊂4 5) V[¯1 (0 ⍬ ¯1)] 123 4