At the risk of exposing my ignorance, how would I test this? I assume
there's an analog to the Clojure example, but it's exact nature escapes me!
Any help appreciated.

-John


On Sun, May 12, 2013 at 1:00 PM, John Benediktsson <mrj...@gmail.com> wrote:

> I ported a Clojure implementation of Conway's Game of Life to Factor.
>> Here is the original Clojure version:
>> http://clj-me.cgrand.net/2011/08/19/conways-game-of-life/
>> Here is my Factor port: http://paste.factorcode.org/paste?id=2932
>> How can I make the Factor variant more elegant and/or idiomatic?
>>
>
> Some ideas:
>
> 1) Your "frequencies" word is the same as "histogram" in math.statistics
> vocabulary.
>
> 2) Your calculation of neighboring cells could use a constant to represent
> the 8  adjacent cells, instead of computing it each time:
>
> CONSTANT: coordinates {
>     { 1 1 }
>     { 1 0 }
>     { 1 -1 }
>     { 0 1 }
>     { 0 -1 }
>     { -1 1 }
>     { -1 0 }
>     { -1 -1 }
> }
>
> : neighbours ( loc -- neighbours )
>   coordinates [ v+ ] with map ;
>
> 3) you might try factoring out the steps in "steps", perhaps something
> like this:
>
> : count-cells ( cells -- counts )
>     [ neighbours ] map concat histogram ;
>
> :: live? ( loc count cells -- ? )
>     count 3 = [ t ] [ count 2 = loc cells in? ] if ;
>
> :: steps ( cells -- cells' )
>     cells count-cells [ cells live? ] assoc-filter keys ;
>
>
>
> ------------------------------------------------------------------------------
> Learn Graph Databases - Download FREE O'Reilly Book
> "Graph Databases" is the definitive new guide to graph databases and
> their applications. This 200-page book is written by three acclaimed
> leaders in the field. The early access version is available now.
> Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
> _______________________________________________
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
>
------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite
It's a free troubleshooting tool designed for production
Get down to code-level detail for bottlenecks, with <2% overhead.
Download for free and get started troubleshooting in minutes.
http://p.sf.net/sfu/appdyn_d2d_ap2
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to