Created
September 1, 2013 16:54
-
-
Save danidiaz/6405694 to your computer and use it in GitHub Desktop.
generating a random vector
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- | Main entry point to the application. | |
| module Main where | |
| import qualified Data.Vector.Unboxed as V | |
| import Control.Monad | |
| import Control.Monad.Random | |
| import System.Random | |
| foovec :: V.Vector Int | |
| foovec = V.singleton 5 | |
| randvec :: MonadRandom m => m (V.Vector Int) | |
| randvec = V.replicateM 5 $ getRandomR (0, 7) | |
| -- | The main entry point. | |
| main :: IO () | |
| main = do | |
| putStrLn $ show $ foovec | |
| seed <- newStdGen | |
| putStrLn $ show $ evalRand randvec seed |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment