Peter,
You might look at the loop special form:
(defn game
"Runs the game, returning the final state"
[]
(loop [state (initial-state)]
(report state)
(if (final? state)
state
(recur (compute-new-state state (read-line))))))
for your own definitions of initial-state, report, final?, and compute-
new-state.
On Nov 5, 3:01 pm, Peter Wolf <[EMAIL PROTECTED]> wrote:
> I just browsed Stuart's wonderful book. Lots of great stuff, which I
> will enjoy working though
>
> However, I didn't find a section that talks about how to do
> non-functional stuff in Clojure. Might be a good section to add for N00Bs
>
> For example, I'm implementing my Mastermind game. I want to prompt the
> user, read a value, change the state of the game, iterate...
>
> For example
>
> Guess 1 >> Blue, Blue, Green, Red
> Response << 1 Black, 2 White
> Guess 2 >> Blue, Green, Red, White
> Response << ...
>
> At some point, almost all interesting programs read input, change state
> and generate output. What is the Clojure way?
>
> Peter
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---