[Haskell-cafe] simple state monad exercises? (besides labeling
lanny at cisco.com
Mon Jul 6 19:42:08 EDT 2009
Off the top of my head state is important when getting from A to B
depends on the path you took. As such a common scenario I find
myself in all the time is not having a good CLI craps game. (And
which I resolve by rewriting in every language I learn.) Stake,
current bet, bets outstanding, point. Lots of state. Also user
interaction, varying output, error conditions, etc. depending on how
complex you want.
A much simpler problem is to model some large number of throws using
different play strategies. Removes all the icky user interaction.
Alternately you can just abuse toy problems.
fac n = execState (facs n) 1
facs n = do
y <- get
if n == 0
then return y
Thomas Hartman wrote:
> Can someone give some simple common scenarios where the state monad is
> useful, besides labeling trees?
> References to puzzles like those in project Euler or similar would be nice.
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
More information about the Haskell-Cafe