File: Initialization.hs

package info (click to toggle)
haskell-splitmix 0.1.0.5-2
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 196 kB
  • sloc: haskell: 1,366; ansic: 151; sh: 53; makefile: 9
file content (28 lines) | stat: -rw-r--r-- 806 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
module Main (main) where

import Control.Monad (forM_, replicateM)
import Data.List     (tails)
import Test.HUnit    (assertFailure)

import qualified System.Random.SplitMix   as SM
import qualified System.Random.SplitMix32 as SM32

main :: IO ()
main = do
    g64 <- replicateM 10 (fmap show SM.initSMGen)
    putStrLn $ unlines g64
    forM_ (tails g64) $ \xs' -> case xs' of
        []     -> return ()
        (x:xs) ->
            if all (x /=) xs
            then return ()
            else assertFailure "ERROR: duplicate"

    g32 <- replicateM 10 (fmap show SM32.initSMGen)
    putStrLn $ unlines g32
    forM_ (tails g32) $ \xs' -> case xs' of
        []     -> return ()
        (x:xs) ->
            if all (x /=) xs
            then return ()
            else assertFailure "ERROR: duplicate"