to be clear, the only change I made to your definition is make the left 
argument 3 3 instead 0f _3 _3.   The example with boxes shows just that _3 _3 
u,:_3 is only different by reversing the content of the cells, which is not 
needed for the conway calculation.


----- Original Message -----
From: Raul Miller <[email protected]>
To: Programming forum <[email protected]>
Cc: 
Sent: Tuesday, June 3, 2014 11:49:49 AM
Subject: Re: [Jprogramming] conway game of life

I didn't optimize for performance when I wrote that page.

I think a faster version would not use boxing nor ;. at all. I just did not
take time to write it. (I expect that something like the classic APL
approach should be faster.)

Boxes are a bow in the direction of popular computing. We've got
significant work to do, though, before they can be efficient. And a lot of
that work is being conducted by groups working on other languages (Haskell,
Agda, Coq, for example). It's largely throwaway work, though, so we'll have
to be careful adopting it.

One of the big problems is that the dogma of type theory mostly works by
avoiding regularity. That's fairly natural: people want to shine. So each
person finds things that they're better at than anyone else, and that's
their yardstick for efficiency.

But too much of that and it all turns into noise.

Thanks,

-- 
Raul






On Tue, Jun 3, 2014 at 7:52 AM, 'Pascal Jasmin' via Programming <
[email protected]> wrote:

> the definition for conway's game of life function that is usually given
> (rosettacode)
>
>    life
> (_3 _3 (+/ e. 3 + 0 , 4&{)@,;._3 ])@(0 , 0 ,~ 0 ,. 0 ,.~ ])
>
> but
>
> (3 3 (+/ e. 3+0,4&{)@, ;._3 ])@(0,0,~0,.0,.~]) is not only a bit shorter,
> its clearer and in j8 2x faster and with 20x less memory use.
>
>    (_3 _3 <;._3 ])@(0 , 0 ,~ 0 ,. 0 ,.~ ]) i.4 4
> ┌───────┬────────┬────────┬───────┐
> │5 4 0  │6 5 4   │7 6 5   │0 7 6  │
> │1 0 0  │2 1 0   │3 2 1   │0 3 2  │
> │0 0 0  │0 0 0   │0 0 0   │0 0 0  │
> ├───────┼────────┼────────┼───────┤
> │9 8 0  │10 9 8  │11 10 9 │0 11 10│
> │5 4 0  │ 6 5 4  │ 7  6 5 │0  7  6│
> │1 0 0  │ 2 1 0  │ 3  2 1 │0  3  2│
> ├───────┼────────┼────────┼───────┤
> │13 12 0│14 13 12│15 14 13│0 15 14│
> │ 9  8 0│10  9  8│11 10  9│0 11 10│
> │ 5  4 0│ 6  5  4│ 7  6  5│0  7  6│
> ├───────┼────────┼────────┼───────┤
> │ 0  0 0│ 0  0  0│ 0  0  0│0  0  0│
> │13 12 0│14 13 12│15 14 13│0 15 14│
> │ 9  8 0│10  9  8│11 10  9│0 11 10│
> └───────┴────────┴────────┴───────┘
>    (3 3 <;._3 ])@(0 , 0 ,~ 0 ,. 0 ,.~ ]) i.4 4
> ┌───────┬────────┬────────┬───────┐
> │0 0 0  │0 0 0   │0 0 0   │0 0 0  │
> │0 0 1  │0 1 2   │1 2 3   │2 3 0  │
> │0 4 5  │4 5 6   │5 6 7   │6 7 0  │
> ├───────┼────────┼────────┼───────┤
> │0 0 1  │0 1  2  │1  2  3 │ 2  3 0│
> │0 4 5  │4 5  6  │5  6  7 │ 6  7 0│
> │0 8 9  │8 9 10  │9 10 11 │10 11 0│
> ├───────┼────────┼────────┼───────┤
> │0  4  5│ 4  5  6│ 5  6  7│ 6  7 0│
> │0  8  9│ 8  9 10│ 9 10 11│10 11 0│
> │0 12 13│12 13 14│13 14 15│14 15 0│
> ├───────┼────────┼────────┼───────┤
> │0  8  9│ 8  9 10│ 9 10 11│10 11 0│
> │0 12 13│12 13 14│13 14 15│14 15 0│
> │0  0  0│ 0  0  0│ 0  0  0│ 0  0 0│
> └───────┴────────┴────────┴───────┘
>
> so is  _3 _3 ,: something that previous versions of J performed better
> with?
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
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