[Haskell] About Random Integer without IO
Georg Martius
mai99dgf at studserv.uni-leipzig.de
Thu Nov 11 10:22:53 EST 2004
Hi,
you need to reallise that Haskell is a pure language. That means a function has the same result if you call it with the same arguments (deterministic). A function that produces random numbers are not of such kind in the first place.
However, what you need to do is to pass the random number generator though the function:
See e.g. System.Random.random [1] which takes the generator and gives you a random value and the new generator back.
Georg
[1] http://www.haskell.org/ghc/docs/latest/html/libraries/base/System.Random.html
PS: this question is more appropriate for haskell-cafe.
On Thu, 11 Nov 2004 14:40:35 +0000, Jose manuel Hernando Cobeña <elreyjoseman at hotmail.com> wrote:
> I need generate random numbers by create polygons with "wxHaskell",
> I am searching in the web, but all I only find IO functions like
>>> test :: Integer -> IO Integer
>>> test n = do x <- randomRIO (1, n)
> return x
> I need this but with types :: Integer -> Integer
>
> Thanks
>
> Escapadas, fines de semana, vacaciones, reservas. Organiza y contrata tus viajes
> aquí.
>
> _______________________________________________
>
> Haskell mailing list
>
> Haskell at haskell.org
>
> http://www.haskell.org/mailman/listinfo/haskell
--
---- Georg Martius, Tel: (+49 34297) 89434 ----
------- http://www.flexman.homeip.net ---------
More information about the Haskell
mailing list