[Haskell-cafe] How to write such a code elegantly ?

z_axis z_axis at 163.com
Mon Jan 10 04:03:25 CET 2011


rollDice n = do 
    tmp <- doesFileExist "/dev/urandom" 
    myGen <- if tmp
        then betterStdGen
        else (mkStdGen . fromInteger) <$> picoSec 
    
    return $ (take 1 $ randomRs (1,n) myGen) !! 0

works but not so elegant?

-----
e^(π.i) + 1 = 0
-- 
View this message in context: http://haskell.1045720.n5.nabble.com/How-to-write-such-a-code-elegantly-tp3334329p3334395.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.



More information about the Haskell-Cafe mailing list