Re: [Haskell-cafe] St. Petersburg Game

2007-11-27 Thread Ketil Malde
[EMAIL PROTECTED] writes: increment b = b + 1 This is also called 'succ' (for successor). main = dolet b = 0 let c = randomRIO (1,2) until (c == 1) increment b return b ERROR StPetersburg.hs:8 - Type error in application *** Expression

Re: [Haskell-cafe] St. Petersburg Game

2007-11-27 Thread Lutz Donnerhacke
* [EMAIL PROTECTED] wrote: 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 import System.Random -- time goes on, interfaces change

Re: [Haskell-cafe] St. Petersburg Game

2007-11-27 Thread Thomas Davie
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

Re: [Haskell-cafe] St. Petersburg Game

2007-11-27 Thread Luke Palmer
On Nov 27, 2007 1:27 PM, [EMAIL PROTECTED] wrote: 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: Yeah, random number generation is one of

Re: [Haskell-cafe] St. Petersburg Game

2007-11-27 Thread pepe
Hola Manolo, What you are trying to do is very easy in Haskell, but you'd better change the approach. In short, you are trying to use b as if it was a mutable variable, which it is not! One could rewrite your program using mutable variables, as below: import Data.IORef import Random

Re: [Haskell-cafe] St. Petersburg Game

2007-11-27 Thread Henning Thielemann
On Tue, 27 Nov 2007 [EMAIL PROTECTED] wrote: 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