Handling of exponent overflow in GNU APL and Dyalog APL (on Mac)

A few weeks ago I started trying a pre-beta release of Dyalog APL (now available as "full beta") for Mac. Fellow Mac users, looks like we are in for a treat after so much time of only having GNU APL and the pretty expensive APLX. Now Mac APL lovers, users and aficionados will have a competitive, commercial option. At last!

I started with the usual 1+1, ⍳ 10 , ⍴ ⍳ 10 to check it worked as expected. Then I moved on to a simple “hello world,” my Mandelbrot one-liner, which is probably the most complex piece of APL I've written. But it didn't work at the first run (I had actually found it out back when I was writing it, since it didn't work on TryAPL.) So I set to find out what the issue may be and learn a little more about APL while at it.

According to ISO/IEC 13751 (Programming Language APL, Extended) there is no clear guideline about what to do with exponent-overflow (or exponent underflow for that matter.) This is relatively usual in ISO specs for programming languages, and is a common pitfall when switching implementations.

Case in point, GNU APL returns infinity on overflow (for instance, you can try 3*1000 to see the difference) whereas Dyalog APL returns Domain error. Of course, both are valid and depending on your code and computation one can be much handier than the other.

My code initially was (copy-pasting it should work, but it is showing more spaces than needed):

⍉' *'[⍎'1+0<|z',(∊150⍴⊂'←c+m×m'),'←c←(¯2.1J¯1.3+(((2.6÷b-1)×(¯1+⍳b))∘.+(0J1×(2.6÷b-1)×(¯1+⍳b←51))))']

The right-most area assumes GNU style, i.e. infinity. Which in a sense behaves like NaN in C: since it is not really a number, the comparison works and I get a nice image after indexing and rotating.

To make it work on Dyalog, the simplest way is adding an intermediate matrix, fixing points that diverge (copy-pasting it should work, but it is showing more spaces than needed)
⍉' *'[⍎'1+2<|z',(∊130⍴⊂'←(d×4>|d)+4×4<|d←c+m×m'),'←c←(¯2.1J¯1.3+(((2.6÷b-1)×(¯1+⍳b))∘.+(0J1×(2.6÷b-1)×(¯1+⍳b←51))))']

And this did the trick, and I leaned some more about how APLs work.
Written by Ruben Berenguel