# perfect-vector-shuffle: Library for performing vector shuffles

[ bsd3, library, program, random, vector ] [ Propose Tags ]

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]

Versions [RSS] [faq] 0.1.0, 0.1.1, 0.1.1.1 CHANGELOG.md base (>=4.9 && <4.15), MonadRandom (>=0.5.1.1 && <0.6), perfect-vector-shuffle, primitive (>=0.6.4 && <0.8), random (>=1.1 && <1.3), vector (>=0.12.0 && <0.13) [details] BSD-3-Clause 2019 Callan McGill callan.mcgill@gmail.com Revision 5 made by callanmcgill at 2021-02-15T23:30:21Z Random, Vector https://github.com/Boarders/perfect-vector-shuffle https://github.com/Boarders/perfect-vector-shuffle/issues head: git clone https://github.com/Boarders/perfect-vector-shuffle by callanmcgill at 2019-10-21T14:39:10Z LTSHaskell:0.1.1.1, NixOS:0.1.1.1 example 1286 total (23 in the last 30 days) (no votes yet) [estimated by Bayesian average] λ λ λ Docs uploaded by userBuild status unknown

## Modules

[Index] [Quick Jump]