|
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
The get is there for the key not present case, and returns kill-cell
appropriately.
Excited to see the final version.
Sean
On Feb 5, 8:15 pm, Aaron Feng <aaron.f...@gmail.com> wrote:
> Hi Sean,
>
> Thanks for all the suggestions. I do plan on improving it iteratively.
>
> > * Use a vector of vectors stored in an agent for env, not a 2D java
> > array. This is a little slower, but mutating arrays in place is not a
> > good example for beginning Clojure. I'll refer to this vector of
> > vectors as a "board"
>
> This was my initial idea, but for some reason I went away from it.
> I'll update it to use vectors.
>
> > * The run fn should take a board in, and return a board one step
> > later. This fits in with Clojure's built in stuff better (see below)
>
> Agreed.
>
> > * Trim down alive & dead cell rules, and use get w/ a default.
> > user=>(defn dead-rule [neigh]
> > (get {3 resurrect-cell} neigh kill-cell))
> > user=>(defn alive-rule [neigh]
> > (get {2 resurrect-cell
> > 3 resurrect-cell}
> > neigh kill-cell))
>
> I really like this improvement. It really reduced the number of
> lines. But technically "get" can be removed from your code, since map
> itself is also a function.
>
> > * decouple the printing from the run fn. Using an agent will really
> > help with this, and make it easier to graft some Swing/SWT/whatever on
> > later.
>
> I actually already started a swing front-end, but I didn't get time to
> finish it. I pushed some updates to my github repo already, I'll make
> more later.
>
> Great suggestions,
>
> Aaron
|
|