Difference between revisions of "Modified Assignment"

From NARS2000
Jump to: navigation, search
Line 7: Line 7:
 
       <td></td>
 
       <td></td>
 
       <td></td>
 
       <td></td>
       <td>is shorthand for <apll>A←A<i>f</i> R</apll>.</td>
+
       <td>is shorthand for <apll>A←A <i></i> R</apll>.</td>
 +
      <td>&nbsp;&nbsp;'''Modified Assignment'''</td>
 
     </tr>
 
     </tr>
 
     <tr>
 
     <tr>
Line 13: Line 14:
 
       <td></td>
 
       <td></td>
 
       <td></td>
 
       <td></td>
       <td>is shorthand for <apll>A[I]←A[I]<i>f</i> R</apll></td>
+
       <td>is shorthand for <apll>A[I]←A[I] <i></i> R</apll></td>
 +
      <td>&nbsp;&nbsp;'''Modified Indexed Assignment'''</td>
 
     </tr>
 
     </tr>
 
     </table>
 
     </table>
Line 25: Line 27:
 
<br />
 
<br />
 
<p>For example, <apll>A+←1</apll> is shorthand for <apll>A←A+1</apll>, and <apll>A,←' '</apll> is shorthand for <apll>A←A,' '</apll>.</p>
 
<p>For example, <apll>A+←1</apll> is shorthand for <apll>A←A+1</apll>, and <apll>A,←' '</apll> is shorthand for <apll>A←A,' '</apll>.</p>
 +
 +
<apll><pre>
 +
      a←⍳¨⍳4
 +
      a
 +
1  1 2  1 2 3  1 2 3 4
 +
      a[3 4]⍴←a[3 4]
 +
      a
 +
1  1 2    1 2 3    1 2 3 4
 +
          1 2 3    1 2 3 4
 +
                    1 2 3 4
 +
                           
 +
                    1 2 3 4
 +
                    1 2 3 4
 +
                    1 2 3 4
 +
</pre></apll>

Revision as of 08:01, 12 August 2019

Af←R is shorthand for A←A R.   Modified Assignment
A[I]f←R is shorthand for A[I]←A[I] R   Modified Indexed Assignment
A is a name with an existing value, I is an arbitrary index to A, f is an arbitrary dyadic function, and R is an arbitrary array.


For example, A+←1 is shorthand for A←A+1, and A,←' ' is shorthand for A←A,' '.

      a←⍳¨⍳4
      a
 1  1 2  1 2 3  1 2 3 4 
      a[3 4]⍴←a[3 4]
      a
 1  1 2    1 2 3     1 2 3 4 
           1 2 3     1 2 3 4 
                     1 2 3 4 
                             
                     1 2 3 4 
                     1 2 3 4 
                     1 2 3 4