Topic: APLX Help : Help on APL language : APL Fundamentals : Multiple specification
[ Previous | Next | Contents | Index | APL Home ]

www.microapl.co.uk

Multiple specification


It is possible to make multiple simultaneous assignments by enclosing a list of variable names in parentheses on the left of an assignment arrow.

             (A B C)← 1 2 3
             A
       1
             B
       2
             C
       3

A scalar to the right of the assignment arrow will be assigned to every item on the left. This is known as 'scalar extension'.

             (A B C)←5
             A
       5
             B
       5
             C
       5
             (A B C)← 'HI' 'THERE' 'FOLKS'
             ⍴A                      (A assigned 'HI' and so on)
       2
             (A B C)←⊂'HI' 'THERE' 'FOLKS'
             ⍴A                      (A, B and C assigned the enclosed vector
       3                              to the right of the assignment arrow)

Caution:

Do not omit the parentheses if you are trying to do multiple specification, as in:

             A B C←5

This expression will assign the value 5 to C and then attempt to evaluate the resultant expression. See also the discussion of binding strengths.


Topic: APLX Help : Help on APL language : APL Fundamentals : Multiple specification
[ Previous | Next | Contents | Index | APL Home ]