execution order

General APL language issues

execution order

Postby giangiquario on Tue Nov 23, 2010 4:44 pm

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?
User avatar
giangiquario
 
Posts: 46
Joined: Thu Nov 26, 2009 8:55 am
Location: Milano, Italia

Re: execution order

Postby JohnS|Dyalog on Thu Nov 25, 2010 10:27 am

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 :-).
JohnS|Dyalog
 


Return to Language

Who is online

Users browsing this forum: No registered users and 1 guest