[comp.lang.c] APL one-liners

eric@snark.uu.net (Eric S. Raymond) (08/27/89)

In <1989Aug26.221107.25606@utzoo.uucp> Henry Spencer wrote:
> I recall seeing an APL guru -- I think it was Iverson himself, in fact --
> turn a straightforward algorithm (polynomial multiplication, I think) into
> a single line of APL.  Quite impressive.  Also impressive that said line
> was quadratic in space and exponential in time, where the original was
> linear in both.

Once, long ago, I was an APL guru (until I learned LISP and got better :-)).

There was a little community of APL experts around the DEC-10 I cut my hacker
teeth on. We used to have `one-liner wars' -- the challenge was to see how
powerful an algorithm you could code in one line of APL. Using the right-arrow
(APL's goto) was acceptable but considered poor form.

I once wrote a gotoless one-liner that, given a string and a text matrix
`dictionary' would convert the string into a vector of lookup indices for
its tokens. Another time I wrote a one-liner `Life' program.

Yes, APL is that powerful. But it's also incredibly slow and a hellish memory
hog in general, and (most damningly) tends to lead to awkward and inefficient
formulations for any algorithm even slightly outside the range of those its
fundamental data types are designed to handle.

I discovered this last when, after being exposed to LISP, I decided to test the
two against each other by a) writing a LISP interpreter in APL, b) writing an
APL interpreter in LISP, and seeing which was easier.

LISP won hands down, of course. So, after about half an hour of cogitation, I
dumped APL and vowed to become expert at the LISP we were using. I did, too.
By writing a manual for it...but that's another story.
-- 
      Eric S. Raymond = eric@snark.uu.net    (mad mastermind of TMN-Netnews)