Strand Assignment: Difference between revisions

From NARS2000
Jump to navigationJump to search
No edit summary
No edit summary
 
(6 intermediate revisions by the same user 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<sub>1</sub> A<sub>2</sub> ... A<sub>n</sub>){is}R</apl></td>
       <td><apll>(A<sub>1</sub> A<sub>2</sub> ... A<sub>n</sub>)←R</apll></td>
       <td></td>
       <td></td>
       <td></td>
       <td></td>
       <td>Assigns the successive items of <apl size="large">R</apl> to the names. </td>
       <td>Assigns the successive items of <apll>R</apll> to the names.</td>
     </tr>
     </tr>
     </table>
     </table>
Line 13: Line 13:
</tr>
</tr>
<tr>
<tr>
   <td><apl size="large">A<sub>1</sub> A<sub>2</sub> ... A<sub>n</sub></apl> are assignable names, <apl size="large">R</apl> is a scalar or vector.
   <td><apll>A<sub>1</sub> A<sub>2</sub> ... A<sub>n</sub></apll> are assignable names, <apll>R</apll> is a scalar or vector.
   </td>
   </td>
</tr>
</tr>
<tr>
<tr>
   <td>If <apl size="large">1&lt;{rho}{rho}R</apl>, signal a <apl size="large">RANK ERROR</apl>.</td>
   <td>If <apll>1&lt;⍴⍴R</apll>, signal a <apll>RANK ERROR</apll>.</td>
</tr>
</tr>
<tr>
<tr>
   <td>If <apl size="large">R</apl> is a scalar or one element vector, its item is assigned to each name, as in <apl size="large">A<sub>i</sub>{is}{disclose}{zilde}{rho}R</apl>.</td>
   <td>If <apll>R</apll> is a scalar or one element vector, its item is assigned to each name, as in <apll>A<sub>i</sub>←⊃⍬⍴R</apll>.</td>
</tr>
</tr>
<tr>
<tr>
   <td>Otherwise, assume there are <apl size="large">n</apl> names in the list:</td>
   <td>Otherwise, assume there are <apll>n</apll> names in the list:</td>
</tr>
</tr>
<tr>
<tr>
   <td>If <apl size="large">n{notequal}{rho}R</apl>, signal a <apl size="large">LENGTH ERROR</apl>.</td>
   <td>If <apll>n≠⍴R</apll>, signal a <apll>LENGTH ERROR</apll>.</td>
</tr>
</tr>
<tr>
<tr>
   <td>Otherwise, each successive item of <apl size="large">R</apl> is assigned to each successive name, as in <apl size="large">A<sub>i</sub>{is}i{disclose}R</apl>.</td>
   <td>Otherwise, each successive item of <apll>R</apll> is assigned to each successive name, as in <apll>A<sub>i</sub>←i⊃R</apll>.</td>
</tr>
</tr>
</table>
</table>
<br />
<br />
<br />
<p>For example, <apll>(A B C)←⊂⍳3</apll> is shorthand for <apll>A←B←C←⍳3</apll>.  In contrast, <apll>(A B C)←⍳3</apll> is shorthand for <apll>A←1 ⋄ B←2 ⋄ C←3</apll>.</p>
For example, <apl size="large">(A B C){is}{enclose}{iota}3</apl> is the same as <apl size="large">A{is}B{is}C{is}{iota}3</apl>.  In contrast, <apl size="large">(A B C){is}{iota}3</apl> is the same as <apl size="large">A{is}1 {diamond} B{is}2 {diamond} C{is}3</apl>.<br />Also, <apl size="large">(A B C){is}(1 2) 'abc' 1.1</apl> is the same as <apl size="large">A{is}1 2 {diamond} B{is}'abc' {diamond} C{is}1.1</apl>, and <apl size="large">(A B){is}B A</apl> is a simple and efficient way to swap the values of the two names.
 
<p>Note that <apll>(A B)←B A</apll> is a simple and efficient way to swap the values of the two names.</p>

Latest revision as of 03:54, 12 April 2008

(A1 A2 ... An)←R Assigns the successive items of R to the names.
A1 A2 ... An are assignable names, R is a scalar or vector.
If 1<⍴⍴R, signal a RANK ERROR.
If R is a scalar or one element vector, its item is assigned to each name, as in Ai←⊃⍬⍴R.
Otherwise, assume there are n names in the list:
If n≠⍴R, signal a LENGTH ERROR.
Otherwise, each successive item of R is assigned to each successive name, as in Ai←i⊃R.


For example, (A B C)←⊂⍳3 is shorthand for A←B←C←⍳3. In contrast, (A B C)←⍳3 is shorthand for A←1 ⋄ B←2 ⋄ C←3.

Note that (A B)←B A is a simple and efficient way to swap the values of the two names.