Conway's Game Of Life in APL

Channel:Dyalog · Length:7:47 · Published:2009-01-26 · Views:235964

Watch on YouTube

Summary

A short Dyalog demonstration building Conway's Game of Life in a single line of APL, step by step. It shows how array operations replace loops.

Why HN recommends it

Recommended whenever APL or array languages come up as the quickest way to see why the paradigm is so striking.

Try watching this video; it will only take you 8 minutes — HN, 2019

Programming language design · Functional programming · Recreational & visual math

Subtitles (excerpt)

here is a vector of the first nine natural numbers the 3X3 reshape gives us a three row three column Matrix which of the items of the Matrix are members of this Vector one for yes zero for no and we'll call this Boolean Matrix R we can embed R in a slightly larger Matrix to 5x7 take of R which pads below and on the right with zeros and we can Center our original within this by doing the ne two rotate around a vertical axis and the neg one rotate around a horizontal axis and we'll call this larger Matrix uppercase R here is a vector of three matrices and we can see this more clearly if we copy in a library function also written in APL which draws boxes around subarrays the 1 by0 by neg one rotate each distributes a rotation between corresponding items in the left and right argument vectors so we see our original zero rotated in the center with a one and a neg one rotation on either side and we can simplify this slightly by having just one copy of R which is enclosed to form a rank zero array which is dist distributed to each item in the left argument Vector so we get the same result next we'll do the one by0 by neg1 outer product column rotation and outer product takes each item of the left

On Hacker News

> Here's a video that really illustrates the power of this paradigm: [VIDEO] Amazing game of life code! — Cactus2018, 2020-08
Try watching this video; it will only take you 8 minutes, but within 3 minutes you should have an idea of why array languages are different from having an ndarray library available in Rust or having typeclasses in Haskell: [VIDEO] After you watch that you will of course suspect that APL and other array languages like J are a sort of DSL for things like numerical linear algebra, which is of course… — kragen, 2019-10
The following video is probably reasonably well known, and I wish that I had a more intelligent commentary than to say that it blows my mind, but it does I think bear out the point of expressivity rather well. [VIDEO] Conway's Game of Life in some 50 characters of APL. — sethrin, 2018-07
While we wait for the site to come back up please enjoy this amazing video showing Conway's Game of Life in APL: [VIDEO] — jboggan, 2015-06
It has an incredible amount of elegant power for some things (see [VIDEO] if you want to immediately fall in love). But I've found that trying to use it for most things just isn't worthwhile. It feels like cheating every time I have to escape from its array programming core to the more familiar flow control structures that only came along in later versions of APL. I think it makes a good puzzle l… — sblom, 2012-04

Related videos