[Haskell-cafe] St. Petersburg Game
manolo at austrohungaro.com
manolo at austrohungaro.com
Tue Nov 27 08:27:09 EST 2007
Hello,
I'm trying to program an implementation of the St. Petersburg game in
Haskell. There is a coin toss implied, and the random-number generation is
driving me quite mad. So far, I've tried this:
import Random
increment :: Int -> Int
increment b = b + 1
main = do let b = 0
let c = randomRIO (1,2)
until (c == 1) increment b
return b
This is intended to print the number of consecutive heads (i.e., 2) before
the first tail, but I get the following error:
ERROR "StPetersburg.hs":8 - Type error in application
*** Expression : until (c == 1) increment b
*** Term : c == 1
*** Type : Bool
*** Does not match : Int -> Bool
I don't really see what's going on, so any help will be more than welcome.
I hope this is a suitable question for the Haskell Café list.
I'm using Hugs in an Ubuntu box, in case that should be useful.
Thanks,
Manolo
More information about the Haskell-Cafe
mailing list