Strand Assignment: Difference between revisions

From NARS2000
Jump to navigationJump to search
No edit summary
No edit summary
Line 33: Line 33:
</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, <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>.


Note that <apll>(A B)←B A</apll> 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>

Revision as of 16:25, 10 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.