Add airlocks
This commit is contained in:
@@ -41,7 +41,7 @@ takeN :: RandomGen g => Int -> [a] -> State g [a]
|
||||
takeN 0 xs = return []
|
||||
takeN i xs = fmap fst $ takeNMore i ([],xs)
|
||||
|
||||
-- to randomly shuffle a list
|
||||
-- | Randomly shuffle a list.
|
||||
shuffle :: RandomGen g => [a] -> State g [a]
|
||||
shuffle xs = do
|
||||
let l = length xs
|
||||
@@ -51,6 +51,10 @@ shuffle xs = do
|
||||
let (_,zs) = mapAccumR f xs rands
|
||||
return zs
|
||||
|
||||
-- | Randomly shuffle the tail of a list, not safe.
|
||||
shuffleTail :: RandomGen g => [a] -> State g [a]
|
||||
shuffleTail (x:xs) = (x :) <$> shuffle xs
|
||||
|
||||
randomSelectionFromList :: RandomGen g => Float -> [a] -> State g [a]
|
||||
randomSelectionFromList p = filterM $ const $ randProb p
|
||||
|
||||
|
||||
Reference in New Issue
Block a user