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 -> I
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
import
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 on
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 err
* [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 chang
[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
> *** Expres
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