Dyalog APL: What are the miracles? Trouble with + and range

69 Views Asked by At

I wonder why is Dyalog APL acting so strange?

      692.4 - 88 - 6.45 - 39.08 - 20 - 53
538.77 ⍝ Fail
      -/ 692.4 88 6.45 39.08 20 53
538.77 ⍝ Fail again
      692.4 - 88
604.4
604.4 - 6.45
597.95
597.95-39.08
558.87
558.87-20
538.87
538.87-53
485.87 ⍝ It's true!

But why? What's the problem with the Dyalog APL?

1

There are 1 best solutions below

0
Jeff Zeitlin On

There is nothing wrong with Dyalog; it is your expectations that are in error.

From the earliest days of the language, APL has evaluated expressions strictly right-to-left, not left-to-right, and not using the BEDMAS. Your expression 692.4 - 88 - 6.45 - 39.08 - 20 - 53 should be evaluated as though it were written conventionally as 692.4 - (88 - (6.45 - (39.08 - (20 - 53)))), which will give you the 538.77 that you consider erroneous.