Assign singleton vector value to a single not yet defined variable in Dyalog APL

125 Views Asked by At

Dyalog APL allows assigning a vector of multiple values to a corresponding number of multiple not yet defined variables:

      x y←1 2
      ]display x
 
1
 
      ]display y
 
2

How to assign a single value from a single-element vector to a single not yet defined variable?

What I tried:

      (⊂x)←,1
VALUE ERROR: Undefined name: x
      (⊂x)←,1
        ∧
      (,⊂x)←,1
VALUE ERROR: Undefined name: x
      (,⊂x)←,1
         ∧
      (,x)←,1
VALUE ERROR: Undefined name: x
      (,x)←,1
        ∧

This works, but it is too dirty:

      (x x)←,1
      ]display x
 
1

The singleton vector is obtained as one of results of a function, and I want to avoid an additional ←⊃ statement after calling the function.

1

There are 1 best solutions below

0
On
x _ ← ,1

While this might also be considered a "workaround", I think it's the cleanest and a similar pattern is fairly common in other programming languages, like the ML family (SML, Ocaml, Haskell), Python, JavaScript...