perfect-vector-shuffle: Library for performing vector shuffles

[ bsd3, library, 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 [faq] 0.1.0, 0.1.1
Change log CHANGELOG.md
Dependencies base (>=4.12.0.0 && <4.13), MonadRandom (>=0.5.1.1 && <0.6), primitive (>=0.6.4.0 && <0.7), random (==1.1.*), vector (>=0.12.0 && <0.13) [details]
License BSD-3-Clause
Copyright 2019
Author Callan McGill
Maintainer callan.mcgill@gmail.com
Category Random, Vector
Home page https://github.com/Boarders/perfect-vector-shuffle
Bug tracker https://github.com/Boarders/perfect-vector-shuffle/issues
Source repo head: git clone https://github.com/Boarders/perfect-vector-shuffle
Uploaded by callanmcgill at Thu Jul 18 17:35:13 UTC 2019
Distributions NixOS:0.1.1
Downloads 121 total (18 in the last 30 days)
Rating (no votes yet) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs uploaded by user
Build status unknown [no reports yet]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees