Hello.
I have the following data and it's constructors:
FigType = TR1 | TR2 | TR3 | TR4 | SQ | L1 | L2 | Z1 | Z2 | Z3 | Z4 | NoFigureI need to randomly return one of them in a function. The obvious solution to me, is simply using a random number generator and case statement, where each value generated is associated with each data constructor. Like this:
import System.Random
randomFigType :: IO FigType
randomFigure = do
x <- randomRIO (1::Int,11::Int)
return $ case x of
1 -> TR1
2 -> TR2
3 -> TR3e t.c.
But is there a more direct way to do this?
Hotmail: Trusted email with Microsoft’s powerful SPAM protection.
Sign up now. _______________________________________________
Beginners mailing list
Beginners@haskell.orghttp://www.haskell.org/mailman/listinfo/beginners