
I'm relatively new to haskell and have some questions: 1- I want to convert an integer to a char( if I say prelude> convert 4 ... it should return prelude> '4') 2- and vice versa? 3- I want to define a function that stores in a variable the following... pretended: (Int,Int,Int,Int) give :: IO Int give = randomRIO (0,9) main = do k <- (give,give,give,give) actualy this isn't possible. but can someone please tell how to do this??? thank you very much --------------------------------- Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now

Looks like homework to me, but for 1 and 2 you might look at read/show, head and (:[]); for 3, try executing the give action multiple times seperately. -- Hal Daume III "Computer science is no more about computers | hdaume@isi.edu than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume On Sat, 30 Nov 2002, Nuno Silva wrote:
I'm relatively new to haskell and have some questions:
1- I want to convert an integer to a char( if I say prelude> convert 4 ... it should return prelude> '4')
2- and vice versa?
3- I want to define a function that stores in a variable the following...
pretended: (Int,Int,Int,Int)
give :: IO Int give = randomRIO (0,9)
main = do k <- (give,give,give,give)
actualy this isn't possible. but can someone please tell how to do this???
thank you very much
--------------------------------- Do you Yahoo!? Yahoo! Mail Plus - Powerful. Affordable. Sign up now

Nuno Silva wrote:
I'm relatively new to haskell and have some questions:
1- I want to convert an integer to a char( if I say prelude> convert 4 ... it should return prelude> '4')
2- and vice versa?
Use chr and ord respectively, from the Char module.
3- I want to define a function that stores in a variable the following...
pretended: (Int,Int,Int,Int)
give :: IO Int give = randomRIO (0,9)
main = do k <- (give,give,give,give)
actualy this isn't possible. but can someone please tell how to do this???
main = do
k1 <- give
k2 <- give
k3 <- give
k4 <- give
let k = (k1, k2, k3, k4)
Or:
main = do
[k1, k2, k3, k4] <- sequence $ replicate 4 give
let k = (k1, k2, k3, k4)
--
Glynn Clements
participants (3)
-
Glynn Clements
-
Hal Daume III
-
Nuno Silva