[Jprogramming] Converting Conways Game Of Life from APL

Ian Gorse unigee at gmail.com
Sun Aug 16 00:41:44 HKT 2009


Hi everyone,

I just been looking at a youtube video of Conways Games Of Life in APL
( http://www.youtube.com/watch?v=a9xAKttWgP4 )

And decided to follow it as much as I could in J. I have included the
time frame in NB. so you can fast foward the video yourself


NB. 0:47
R=. _1 _2 |. 5 7 {. r=. (3 3 $ i.9) e. 1 2 3 4 7

   R
0 0 0 0 0 0 0
0 0 0 1 1 0 0
0 0 1 1 0 0 0
0 0 0 1 0 0 0
0 0 0 0 0 0 0

NB. 1:00
   R;R;R
┌─────────────┬─────────────┬─────────────┐
│0 0 0 0 0 0 0│0 0 0 0 0 0 0│0 0 0 0 0 0 0│
│0 0 0 1 1 0 0│0 0 0 1 1 0 0│0 0 0 1 1 0 0│
│0 0 1 1 0 0 0│0 0 1 1 0 0 0│0 0 1 1 0 0 0│
│0 0 0 1 0 0 0│0 0 0 1 0 0 0│0 0 0 1 0 0 0│
│0 0 0 0 0 0 0│0 0 0 0 0 0 0│0 0 0 0 0 0 0│
└─────────────┴─────────────┴─────────────┘


NB. 1:14... surely there is a better way to do this??
   |: each 1 0 _1 |. each |: each R;R;R
┌─────────────┬─────────────┬─────────────┐
│0 0 0 0 0 0 0│0 0 0 0 0 0 0│0 0 0 0 0 0 0│
│0 0 1 1 0 0 0│0 0 0 1 1 0 0│0 0 0 0 1 1 0│
│0 1 1 0 0 0 0│0 0 1 1 0 0 0│0 0 0 1 1 0 0│
│0 0 1 0 0 0 0│0 0 0 1 0 0 0│0 0 0 0 1 0 0│
│0 0 0 0 0 0 0│0 0 0 0 0 0 0│0 0 0 0 0 0 0│
└─────────────┴─────────────┴─────────────┘

Now this is where I am stuck.
At 1:56 in the video, he creates 9 copies of R (3 3 $
R;R;R;R;R;R;R;R;R), and rotates each one using "outer product column
rotation"
(sorry I don't know how to explain it any better, so you will need to
check the video yourself)

Can someone please explain how this can be achieved in J?

Thanks


More information about the Programming mailing list