[Haskell-cafe] Random Number

2009-06-07 Thread ptrash
Hi, is the are way (or a build in method) in haskell to get a random number from a number bottom to a number top? Something like let randomNumber = random 1 30 to get a random number between 1 and 30. -- View this message in context:

Re: [Haskell-cafe] Random Number

2009-06-07 Thread José Prous
look in System.Random randomRIO :: (Random a) = (a, a) - IO a you can do randomNumber-randomRIO (1,30) On Sun, Jun 7, 2009 at 3:33 PM, ptrash ptr...@web.de wrote: Hi, is the are way (or a build in method) in haskell to get a random number from a number bottom to a number top? Something

Re: [Haskell-cafe] Random Number

2009-06-07 Thread Krzysztof Skrzętnicki
On Sun, Jun 7, 2009 at 21:33, ptrashptr...@web.de wrote: Hi, is the are way (or a build in method) in haskell to get a random number from a number bottom to a number top? Something like let randomNumber = random 1 30 to get a random number between 1 and 30. I don't mean to be rude, but

Re: [Haskell-cafe] Random Number

2009-06-07 Thread Iain Barnett
On 7 Jun 2009, at 8:33 pm, ptrash wrote: Hi, is the are way (or a build in method) in haskell to get a random number from a number bottom to a number top? Something like let randomNumber = random 1 30 to get a random number between 1 and 30. rand :: Int - Int - IO Int rand low high =

Re: [Haskell-cafe] Random Number

2009-06-07 Thread michael rice
Good essay. Try this one for a laugh: http://www.mcs.vuw.ac.nz/comp/Publications/CS-TR-02-9.abs.html A good place to begin is PDF pg. 19. Michael --- On Sun, 6/7/09, Krzysztof Skrzętnicki gte...@gmail.com wrote: From: Krzysztof Skrzętnicki gte...@gmail.com Subject: Re: [Haskell-cafe

Re: [Haskell-cafe] Random number example

2009-04-28 Thread Ross Mellgren
: From: michael rice nowg...@yahoo.com Subject: Re: [Haskell-cafe] Random number example To: Ross Mellgren rmm-hask...@z.odi.ac Cc: haskell-cafe@haskell.org Date: Thursday, April 23, 2009, 5:49 PM Hi Ross, Thanks for going the extra mile. A lot of what you did I haven't seen before, so it's going

Re: [Haskell-cafe] Random number example

2009-04-26 Thread michael rice
= (\die2 - return (die1 + die2))) rollNDice :: Int - Random [Int] --- On Thu, 4/23/09, michael rice nowg...@yahoo.com wrote: From: michael rice nowg...@yahoo.com Subject: Re: [Haskell-cafe] Random number example To: Ross Mellgren rmm-hask...@z.odi.ac Cc: haskell-cafe@haskell.org Date: Thursday

[Haskell-cafe] Random number example

2009-04-23 Thread michael rice
I pretty much followed the sequence of steps that led to this final code (see below), but will be looking it over for a while to make sure it sinks in. In the meantime, I get this when I try to use it (sumTwoDice) at the command line: [mich...@localhost ~]$ ghci rand9 GHCi, version 6.10.1:

Re: [Haskell-cafe] Random number example

2009-04-23 Thread Daniel Fischer
Am Donnerstag 23 April 2009 17:28:58 schrieb michael rice: I pretty much followed the sequence of steps that led to this final code (see below), but will be looking it over for a while to make sure it sinks in. In the meantime, I get this when I try to use it (sumTwoDice) at the command line:

Re: [Haskell-cafe] Random number example

2009-04-23 Thread Ross Mellgren
So there are a couple problems. First is you are trying to rebind prelude functions, when instead you should be creating an instance of Monad. This requires a bit of shuffling because without language extensions you can't instance Monad Random for your type of Random, as it is a type

Re: [Haskell-cafe] Random number example

2009-04-23 Thread Brandon S. Allbery KF8NH
On Apr 23, 2009, at 11:28 , michael rice wrote: interactive:1:0: No instance for (Show (Seed - (Int, Seed))) arising from a use of `print' at interactive:1:0-9 Possible fix: add an instance declaration for (Show (Seed - (Int, Seed))) In a stmt of a 'do' expression: print

Re: [Haskell-cafe] Random number example

2009-04-23 Thread michael rice
-cafe] Random number example To: michael rice nowg...@yahoo.com Cc: haskell-cafe@haskell.org Date: Thursday, April 23, 2009, 11:51 AM So there are a couple problems. First is you are trying to rebind prelude functions, when instead you should be creating an instance of Monad. This requires a bit

[Haskell-cafe] random number generators

2007-03-22 Thread david karapetyan
hi, i have been trying to learn haskell and i would like to translate the following object-oriented pseudo-code into working haskell code but i'm stumped on how to write the next function in the haskell code. any help is appreciated. class Random ... end ran = Random.new(300) ran.next() - this

Re: [Haskell-cafe] random number generators

2007-03-22 Thread Paul Johnson
david karapetyan wrote: hi, i have been trying to learn haskell and i would like to translate the following object-oriented pseudo-code into working haskell code but i'm stumped on how to write the next function in the haskell code. any help is appreciated. class Random ... end ran =