# perfect-vector-shuffle

Library for performing vector shuffles

https://github.com/Boarders/perfect-vector-shuffle

 Version on this page: 0.1.1.1@rev:4 LTS Haskell 18.28: 0.1.1.1@rev:5 Stackage Nightly 2021-06-14: 0.1.1.1@rev:5 Latest on Hackage: 0.1.1.1@rev:5

See all snapshots `perfect-vector-shuffle` appears in

Maintained by
This version can be pinned in stack with:`perfect-vector-shuffle-0.1.1.1@sha256:8656a3f1f491d1d79aba9e0a5dbb08589613202b08c7a9b92570d6bec7390093,3668`

#### Module documentation for 0.1.1.1

• Immutable
• Mutable
Depends on 6 packages(full list with versions):
Used by 1 package in lts-16.31(full list with versions):

This package contains functions for performing in-place Fisher--Yates shuffles on mutable and immutable vectors along with some related functionality. The shuffles are uniform at random amongst all permuations.

For an example of how to use it:

``````module Main where

import Data.Vector
import Immutable.Shuffle

main :: IO ()
main = do {
shuffleMyVector >>= print;
cycleMyVector   >>= print;
derangeMyVector >>= print;
}

myVector :: Vector Int
myVector = fromList [1..10]

shuffleMyVector :: IO (Vector Int)
shuffleMyVector = shuffleM myVector

cycleMyVector :: IO (Vector Int)
cycleMyVector = maximalCycleM myVector

derangeMyVector :: IO (Vector Int)
derangeMyVector = derangementM myVector
``````

This gives the following:

``````>>> main
[2,8,1,5,10,9,7,3,6,4]
[6,8,4,10,9,2,5,7,3,1]
[8,5,4,1,10,9,3,6,2,7]

>>> main
[7,9,3,5,10,6,8,1,2,4]
[2,4,10,7,8,1,5,9,3,6]
[4,8,5,2,7,3,9,6,10,1]
``````

# Changelog

## [0.1.1] - 2019-07-18

• Added sample without replacement, maximal cycle and derangement functions
• Added test coverage for all new functionality