[EMAIL PROTECTED] writes:

> increment b = b + 1

This is also called 'succ' (for successor).

> main =  do    let b = 0
>               let c = randomRIO (1,2)
>               until (c == 1)  increment b
>               return b

> ERROR "StPetersburg.hs":8 - Type error in application
> *** Expression     : until (c == 1) increment b
> *** Term           : c == 1
> *** Type           : Bool
> *** Does not match : Int -> Bool

  Prelude> :t until
  until :: (a -> Bool) -> (a -> a) -> a -> a

So until wants a function from a something to a boolean, but you are
giving it (c==1) which is just a boolean.

More generally, I think you should solve this in a more functional
style, perhaps using randomRs to get a list of coin tosses, and take
what you need from that.

-k
-- 
If I haven't seen further, it is by standing in the footprints of giants
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to