Strand Assignment: Difference between revisions

From NARS2000
Jump to navigationJump to search
No edit summary
No edit summary
Line 34: Line 34:
<br />
<br />
<br />
<br />
For example, <apl size="large">(A B C){is}{enclose}{iota}3</apl> assigns <apl size="large">{iota}3</apl> to each of the names <apl size="large">A</apl>, <apl size="large">B</apl>, and <apl size="large">C</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>
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.

Revision as of 13:57, 9 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 the same as A←B←C←⍳3. In contrast, (A B C)←⍳3 is the same as A←1 ⋄ B←2 ⋄ C←3.
Also, (A B C)←(1 2) 'abc' 1.1 is the same as A←1 2 ⋄ B←'abc' ⋄ C←1.1, and (A B)←B A is a simple and efficient way to swap the values of the two names.