The m-surrounding-neighbors-seq function only memoizes sequences  
containing Refs surrounding a particular ref at (x,y). I do this to  
avoid the recalculation of the coordinates of the cells surrounding  
each cell. As I understand it, memoization caches return values for  
input values.

For example, the the Ref for cell (3,4) has Refs at [(2,3) (3,3) (4,3)  
(2,4) (4,4) (2,5) (3,5) (4,5)] surrounding it. It is only memoizing a  
sequence of these Refs, once for each point in the grid, not for every  
grid. If it was indeed doing that it wouldn't take long before the JVM  
ran out of memory- the simulation is very unlikely to hit a cycle :)


Use the clojure libs I include in the bundle on my website: 
http://www.solussd.com/wp-content/uploads/2009/11/highlife.zip


---
Joseph Smith
j...@uwcreations.com
(402)601-5443





On Nov 16, 2009, at 8:24 PM, Jeff Heon wrote:

> Hi there,
>
> Unfortunately, I was unable to get it working.
> From what I gather, I'm using the wrong clojure.jar and or clojure-
> contrib.jar.
>
> Could you tell me which version of theses files you are using?
>
> Anyway, I was wondering about the memoizing of the function
> surrounding-neighbors-seq.
>
> It's memoizing for every grid, which I guess is good if the
> application hits a cycle, but if it doesn't, it will unnecessarily
> keep function results for passed grids.
>
> I'm not sure about the memoizing cache behavior, but if we bet for  
> non-
> repeating grids, I think it might be better to dynamically memoize for
> each grid only.
> This way, memoizing information for passed grids will be GCed.
>
> I'm thinking about something like this.
> Remove the global def:
> (def m-surrounding-neighbors-seq (memoize surrounding-neighbors-seq))
>
> Modify the two following count-living-neighbors and get-living-
> neighbors-seq functions to let a memoized version once for each grid:
> See http://paste.lisp.org/display/90541
>
> Using a let and passing the local memoized function to count-living-
> neighbors felt weird, but it felt better than doing a binding.
>
> I wonder which would be the idiomatic way to go.
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient  
> with your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to