On Wed, Jan 7, 2009 at 3:13 AM, Tom Ayerst <[email protected]> wrote:
> Hi Mark,
>
> I think you are replacing globals with a "god" structure (game) which passed
> to every function, I think you need to abstract more.
That's definitely what I'm doing and I don't like it either. I just
haven't worked out a better alternative yet. Some of the functions use
many parts of the game state, so for those it seems appropriate to
just pass the game rather than a large number of arguments extracted
from the game.
For other functions that don't use very many pars of game, maybe I
should use more parameters. For example,
(defn win? [game]
(let [snake (game :snake)
body (snake :body)]
(= (count body) (game :length-to-win))))
Would you recommend that I change it to this and make the caller pass
two parameters?
(defn win? [snake length-to-win]
(= (count (snake :body) (game length-to-win)))
--
R. Mark Volkmann
Object Computing, Inc.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---