Continuation of the line in APL

Is there a line continuation character in APL i.e. a character that indicates input is not yet complete and continues parsing the next line?

The reason I want is to enter an array in a format similar to its form, for example instead of:

Forecast ← 4 6 ⍴ 150 200 100 80 80 80 300 330 360 400 500 520 100 250 350 380 400 450 50 120 220 300 320 350

      

I would like to write (where \

is the hypothetical continuation character):

Forecast ← 4 6 ⍴ \
150 200 100  80  80  80 \
300 330 360 400 500 520 \
100 250 350 380 400 450 \
 50 120 220 300 320 350

      

I'm using GNU APL if that's important and I'm pretty much a complete newbie, so I'm sorry if I just haven't seen it yet.

+3


source to share


3 answers


No, there is nothing like the line continuation character in any modern version of APL that I know of.

But you have a point - visual fidelity in defining arrays is important, but it has never really been considered at the language level.

I would probably do

Forecast ← 4 6 ⍴ 150 200 100 80 80 80, 300 330 360 400 500 520, 100 250 350 380 400 450, 50 120 220 300 320 350

      



or

Forecast ← 0 ⍴ 0
Forecast ← Forecast, 150 200 100  80  80  80 
Forecast ← Forecast, 300 330 360 400 500 520 
Forecast ← Forecast, 100 250 350 380 400 450 
Forecast ← Forecast,  50 120 220 300 320 350
Forecast ← 4 6 ⍴ Forecast

      

when formatting is needed.

Several years ago, some versions of APL allowed you to enter character strings with inline carriage returns in functions, simply without inserting a trailing quote until you were done. This function had a similar effect, but only for lines and only for one function line. It was eventually removed from IBM APL and Sharp APL, possibly many others. Perhaps it was confusing to users who were stuck with what appeared to be an input loop, or perhaps del's own editor was unable to process such lines afterwards.

+5


source


With GNU APL (and possibly other versions), you can use the following syntax:

A ← βŠƒβŽΒ¨βŽ•INP 'END'
  1 0 0
  0 1 0
  0 0 1
 'END'

      



Hello

+2


source


Dyalog MiServer uses a nifty command that allows the developer to include the JS code that is needed as part of the page in the APL code through the ScriptFollows function, which simply scans the lines following this statement and returns all the text from the next segment of the continuously commented lines. This idea can also be (ab-) used for your query:

βˆ‡ foo
⍝ required functions need to be in the WS or can be defined here:
 dtlb←{⍡{((∨\⍡)∧⌽∨\⌽⍡)/⍺}' '≠⍡}   ⍝ delete trailing blanks
 ScriptFollows←{{∊{'⍝'=βŠƒβ΅:'' β‹„ ' ',dtlb ⍡}Β¨1↓¨⍡/⍨∧\'⍝'=βŠƒΒ¨β΅}dtlbΒ¨(1+2βŠƒβŽ•LC)β†“βŽ•NR 2βŠƒβŽ•SI}
⍝ end of initialization...
⍝ and then could just write:

 arr←4 4⍴2βŠƒβŽ•VFI ScriptFollows ⍬
⍝ 1 2 3 4
⍝ 5 6 7 8
⍝ 9 10 11 12
⍝ 13 14 15 16
βˆ‡

      

Disadvantage: The rho of the array must be specified independently of the data, so when you need to edit the data, you have to edit in two places. Other than that, I must say that I really fell in love with this ScriptFollows

-Stuff; -)

+2


source







All Articles