Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Line continuations in APL

Tags:

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 it is to input an array in a format similar to its shape, e.g., 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'd 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 it's important, and I'm an almost-complete novice, so apologies if I simply haven't seen it yet.

like image 885
benizi Avatar asked Feb 17 '26 15:02

benizi


2 Answers

No, there is nothing like a 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 addressed at the language level.

I would probably have done

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 explicit formatting was necessary.

Years ago, some versions of APL allowed you to enter character strings with embedded carriage returns in functions by simply not entering the trailing quote until you were done. This feature had a similar effect, but only for strings, and only on a single function line. It was eventually removed from IBM APL and Sharp APL, probably many others. It may have been confusing for users who got stuck in what appeared to be an input loop, or maybe the native del editor could not handle such lines afterwards.

like image 193
Lobachevsky Avatar answered Feb 21 '26 15:02

Lobachevsky


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

A ← ⊃⍎¨⎕INP 'END'
  1 0 0
  0 1 0
  0 0 1
 'END'

Regards

like image 20
Thomas Baruchel Avatar answered Feb 21 '26 14:02

Thomas Baruchel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!