execution order

General APL language issues
Post Reply
User avatar
giangiquario
Posts: 46
Joined: Thu Nov 26, 2009 8:55 am
Location: Milano, Italia

execution order

Post by giangiquario »

Please consider the following behaviour (in a clear workspace):

Code: Select all

 
      ⊂[1↓⍳⍴⍴wsx]wsx←2 3⍴⍳5
VALUE ERROR
      ⊂[1↓⍳⍴⍴wsx]wsx←2 3⍴⍳5
             ∧


Maybe incorrect?
JohnS|Dyalog

Re: execution order

Post by JohnS|Dyalog »

Hi Gianluigi

Dyalog allows:

Code: Select all

      v←0 0 0
      v[1] n ← 2 3   ⍝ assign n and first item of v
      v n
 2 0 0  3

In this case, the interpreter has to evaluate the expression as far to the left as the v before deciding whether the brackets form an index (if v is an array) or an axis (as in your example) if v is a function.

It cannot skip over the []s to have a peek, because APL also allows, in a clear WS:

Code: Select all

      v[v←⍳3]←1

Morten suggests this elegant code-around for your example:

Code: Select all

      {⊂[1↓⍳⍴⍴⍵]⍵}2 3⍴⍳5

Strange things, brackets; you can see why J removed them :-).
Post Reply