actions

2002-12-04 Thread Nuno Silva
I'm using an action that generates a random number, for the user to discover it. each time he guesses, if the number is diferent that the one generated, it is suposed to call itself again to try again, but each time I call it, it generates the number again.
how can I overcome this?
sample of the code:
descodificador = do c1 - gera   c2 - gera   c3 - gera   c4 - gera 
 "code in the middle to check if the number is equal"
 if not than go down...
 descodificador

Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now

Re: actions

2002-12-04 Thread Nick Name
On Wed, 4 Dec 2002 05:54:43 -0800 (PST)
Nuno Silva [EMAIL PROTECTED] wrote:

 descodificador  =   do c1 - gera
 c2 - gera
 c3 - gera
 c4 - gera 
 
code in the middle to check if the
number is equal 
 
 if not than go down... 
 
 descodificador 


Perhaps it's better to post the real code. Mind code layout first, and
if you create the random generator OUTSIDE the descodificador and use
one of the pure functions (not actions) to get a random number from it,
like random, and reuse THE SAME generator, you will always get the
same number.

You can use the new generator obtained as the second element of the
resulting couple from the function random or the infinite list of
random numbers obtained with the function randoms

Vincenzo
___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe