Modified Assignment: Difference between revisions

From NARS2000
Jump to navigationJump to search
No edit summary
m (WikiSysop moved page Modify Assignment to Modified Assignment without leaving a redirect)
 
(5 intermediate revisions by 2 users not shown)
Line 4: Line 4:
     <table border="0" cellpadding="5" cellspacing="0" summary="">
     <table border="0" cellpadding="5" cellspacing="0" summary="">
     <tr>
     <tr>
       <td><apl size="large"> A<i>fn</i>←R</apl></td>
       <td><apll>A<i>f</i>←R</apll></td>
       <td></td>
       <td></td>
       <td></td>
       <td></td>
       <td>is shorthand for <apl size="large">A←A<i>fn</i> R</apl>.</td>
       <td>is shorthand for <apll>A←A <i></i> R</apll>.</td>
      <td>&nbsp;&nbsp;'''Modified Assignment'''</td>
     </tr>
     </tr>
     <tr>
     <tr>
       <td><apl size="large">A[I]<i>fn<i>←R</apl></td>
       <td><apll>A[I]<i>f<i>←R</apll></td>
       <td></td>
       <td></td>
       <td></td>
       <td></td>
       <td>is shorthand for <apl size="large">A[I]←A[I]<i>fn</i> R</apl></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 19: Line 21:
</tr>
</tr>
<tr>
<tr>
   <td><apl size="large">A</apl> is a name with an existing value, <apl size="large">I</apl> is an arbitrary index to <apl size="large">A</apl>, <apl size="large">R</apl> is an arbitrary array.
   <td><apll>A</apll> is a name with an existing value, <apll>I</apll> is an arbitrary index to <apll>A</apll>, <apll><i>f</i></apll> is an arbitrary dyadic function, and <apll>R</apll> is an arbitrary array.
   </td>
   </td>
</tr>
</tr>
</table>
</table>
<br />
<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>
For example, <apl size="large">A+{is}1</apl> is shorthand for <apl size="large">A{is}A+1</apl>, and <apl size="large">A,{is}' '</apl> is shorthand for <apl size="large">A{is}A,' '</apl>.
 
<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>

Latest revision as of 14:03, 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