
Conway's Game of Life in One Line of APL (2007) - pmoriarty
http://catpad.net/michael/apl/
======
emersonrsantos
In one line of J (both APL and J were created by Kenneth E. Iverson)

life=: (3 3 (+/ e. 3+0,4&{)@,;._3 ])@(0,0,~0,.0,.~])

Given a life instance, the next generation can be found by:

1\. adding extra empty cells, surrounding the life instance,

2\. tessellating the result, finding every overlapping 3 by 3 subinstance,

3\. totaling the number of live cells in each subinstance,

4\. treating a subinstance as a live cell iff that total is a member of the
sequence 3,x where x is 3 if the center cell was previously dead, and 4 if the
center cell was previously alive (that said, note that 4 is also the index of
the center cell, with the sub instance arranged as a flat list).

~~~
rebootthesystem
<rant on>

Please, people, stop using, promoting or even placing J on the same footing as
APL. It is an absolute abomination of a language. It's ONLY motivation was
that doing non-ASCII characters was really difficult way-back-when. That's it.
And in creating J they absolutely butchered the very principles Iverson and
others were vocal and passionate about promoting and teaching.

I learned APL about thirty years ago. Yes, we had computers thirty years ago.
I learned it from what I'll call "first generation APL'ers". It's like saying
"the first inner circle who started to dabble in Linux as soon as Linus made
is public". The first disciples of Iverson, if you will. So, I am two levels
away from Iverson. I met him multiple times at conferences, seminars and APL
university meets. Him and other APL pioneers like Ray Polivka, Sandra Pakin,
James Brown, Adrian Smith and Paul Berry. All of these people wrote books
about APL and taught it.

Big deal, right? Well, yeah. Because I was in the room, a very small room,
with maybe 200 people, if not 100, when this paper was presented by Iverson
himself (in fact, I have a picture with him at the event):

[http://www.eecg.toronto.edu/~jzhu/csc326/readings/iverson.pd...](http://www.eecg.toronto.edu/~jzhu/csc326/readings/iverson.pdf)

Notation as a Tool of Thought was an incredible eye opening paradigm for me
back then. I sat there listening to this presentation that pulled together all
had learned about APL during the prior year or two of using it. And it was
revelation. Notation made the power of the APL concept that much more than the
ideas of easy array manipulation. It brought computational problem solving to
a level of expression matching mathematical notation. This was way ahead of
it's time and I felt privileged to be among the first generation of people
using it.

Yet, there was a problem. Machines of the time made it difficult to work with
non-ASCII character sets. We had to use specialized terminals (IBM and
Tektronix made some).

When the IBM PC came out we had to literally burn a custom character set ROM
for the graphics card and replace the line drawing characters with APL
characters. That was great, but it sure didn't make for easily opening up APL
to the masses. You had to be very, very interested in APL to not only buy an
expensive APL interpreter but also engage in swapping chips out of your
computer. The language was definitely ahead of it's time. In some cases you
had to buy very specific hardware or it would not work.

As PC's exploded and portables like the early Compaq's came out it became more
and more difficult to deal with the character set.

And so, I remember going to APL conferences where the concept of
transliterating the language started to surface. The idea being to use a set
of ASCII characters to represent APL characters and, therefore, enable this
franken-APL to be accessible without hardware mods to your computer.

This was incredibly short-sighted. Many of us knew it was a matter of time
before graphical display of symbols (like math and music notation) would be
easy.

Eventually this evolved into J. A notation that completely abandoned the paper
that earned Iverson the ACM Turing Award. It's APL without perhaps the most
powerful thing about APL. It looks like a terminal shitting characters because
it is operating at the wrong baud rate. Iverson made a huge mistake with J and
he abandoned EVERYTHING he was so right to champion years earlier.

If we are ever going to go in that direction again (I think we have to, in
some form) we need to understand that notation, more than almost anything
else, was the key.

Computational problem solving needs to evolve beyond a state where the best we
can do is type English words into a text editor and into something that is far
more expressive. For that you need a notation, not an abomination like J.

<rant off>

~~~
eggy
I use both J and Dyalog APL. It is my understanding that Arthur Whitney, Roger
Hui and Ken Iverson himself worked on J. The goal was not just to address the
difficulty of using non-ASCII character, but to add funtional programming,
hook and fork, easier tacit programming and fix certain other issues that even
Ken Iverson himself acknowledged [1][2].

PS: I use Dyalog APL because I do personally like the once-alien-to-me
characters!

[1]
[http://www.jsoftware.com/papers/APLPersonalView.htm](http://www.jsoftware.com/papers/APLPersonalView.htm)
[2]
[http://www.jsoftware.com/papers/autobio.htm](http://www.jsoftware.com/papers/autobio.htm)

~~~
beagle3
> to add funtional programming, hook and fork, easier tacit programming and
> fix certain other issues that even Ken Iverson himself acknowledged

Whitney and Iverson disagreed about a lot of these things - e.g. Whitney
prefers scan and fold to go left-to-right, rather than Iverson's right-to-
left. Iverson is consistent with the rest of the language, Whitney is not
(though much more practical). Also, Iverson added hook and fork; Whitney
preferred the much simpler multi-monadic or dyadic-multi-monadic
juxtaposition.

I don't remember where I read this, but I do remember reading Iverson
conceding that Whitney's practical approach is probably a better idea than his
own pure approach.

------
rgiar
For an infinitely more relaxing experience of life in APL, may I recommend:
[http://youtu.be/a9xAKttWgP4](http://youtu.be/a9xAKttWgP4)

I've watched it many times but I still expect him to mention happy little
trees :)

------
bbanyc
Having dealt with APL in the past, I've always been a bit skeptical of the
"Blub Paradox" and other forms of Lisp triumphalism. APL is clearly far more
powerful that any other language in some respects and far more limited in
others.

On that note -
[http://c2.com/cgi/wiki?JoelMosesOnAplAndLisp](http://c2.com/cgi/wiki?JoelMosesOnAplAndLisp)

------
JosephHatfield
I have discovered a truly remarkable non nested-array solution which this
margin is too small to contain.

