take a look at the life demo
On Mar 25, 2013 4:22 PM, "Jeremy Smith" <[email protected]>
wrote:

> Hi everyone,
>
> I'm am amateur trying to learn J.  Someday I hope to apply the language in
> an actuarial context, but first I'm trying to get some chops.  As a
> challenge, I've been trying to program The Game of Life using J.  I'm
> attempting to directly translate the APL version described here:
> http://www.youtube.com/watch?v=a9xAKttWgP4
>
> So far I've come up with this, which seems to match the "life" function
> that is defined in the video, around timestamp 3:52:
>
> life =: +./@((1 ,: [) (*."2) 3 4 e."0/ +/@(+/@(1 0 _1 |."0 2/ 1 0 _1 |."0
> 1/ [)))
>
> What I'd like to do next is create the "gen" function as shown in the video
> at about 4:10.  The command "n gen board" should return the first n
> generations of the Game of Life for any given starting board (see the
> video).
>
> I can write this:
>
> gen=: life^:
>
> And then (i.4) gen board indeed gives me what I want.  But I cannot figure
> out how to define "gen" so that the syntax "4 gen board" (i.e., without the
> i. in the left hand argument) works the same way.  Can anyone help?
>
> Thanks,
> Jeremy
>
> p.s. Let me hasten to add this: I am sure many of you have your own
> implementation of The Game of Life.  No doubt, almost all of these are
> much, much superior to the one I've come up with.  But with all due
> respect, at this point I'm really only interested in solving this
> particular narrow problem of combining power and iteration in a verb
> definition.  Thanks for your understanding.
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to