1

I saw this logic and wonder why the result is one rather than zero:

      P ← 1 1 0
      Q ← 0 0 1
      ∨/ P ∧← Q
1

On the other hand the following results in zero:

      P ← 1 1 0
      Q ← 0 0 1
      ∨/ P ← P ∧ Q
0

I'm using Dyalog APL 16.

August Karlstrom
  • 10,773
  • 7
  • 38
  • 60

1 Answers1

3

The result of any assignment is the value to the right of the assignment arrow, so P ∧← Q returns Q while P ← P ∧ Q returns P ∧ Q which is also the new value assigned to P, per the documentation:

Assignment (Modified)   {R}←Xf←Y

(…)

R is the “pass-through” value, that is, the value of Y. If the result of the derived function is not assigned or used, there is no explicit result.

To get the performance benefit of in-place modification, while using the new value inline, you can write ∨/ P ⊣ P ∧← Q

Adám
  • 6,573
  • 20
  • 37