Copyright | (c) Eric Mertens 2017 |
---|---|
License | ISC |
Maintainer | emertens@gmail.com |
Safe Haskell | None |
Language | Haskell2010 |
Common permutations of a finite collection of elements and operations on them.
Synopsis
- data Permutation (n :: Nat)
- runPermutation :: forall a (n :: Nat). (Int -> a) -> Permutation n -> [a]
- mkPermutation :: forall (n :: Nat). KnownNat n => (Int -> Int) -> Permutation n
- swap :: forall (n :: Nat). KnownNat n => Int -> Int -> Permutation n
- rotateRight :: forall (n :: Nat). KnownNat n => Int -> Permutation n
- rotateLeft :: forall (n :: Nat). KnownNat n => Int -> Permutation n
- invert :: forall (n :: Nat). Permutation n -> Permutation n
- isValid :: forall (n :: Nat). Permutation n -> Bool
- size :: forall (n :: Nat). Permutation n -> Int
- backwards :: forall (n :: Nat). KnownNat n => Permutation n
- cycles :: forall (n :: Nat). Permutation n -> [[Int]]
- order :: forall (n :: Nat). Permutation n -> Int
Documentation
data Permutation (n :: Nat) Source #
Permutations of n
elements
Instances
runPermutation :: forall a (n :: Nat). (Int -> a) -> Permutation n -> [a] Source #
mkPermutation :: forall (n :: Nat). KnownNat n => (Int -> Int) -> Permutation n Source #
Given a function mapping incoming indices to outgoing ones, construct a new permutation value.
swap :: forall (n :: Nat). KnownNat n => Int -> Int -> Permutation n Source #
Permutation generated by swapping the elements at a pair of indices.
rotateRight :: forall (n :: Nat). KnownNat n => Int -> Permutation n Source #
Permutation generated by rotating all the elements to the right.
rotateLeft :: forall (n :: Nat). KnownNat n => Int -> Permutation n Source #
Permutation generated by rotating all the elements to the left.
invert :: forall (n :: Nat). Permutation n -> Permutation n Source #
Permutation generated by inverting another permutation.
isValid :: forall (n :: Nat). Permutation n -> Bool Source #
Validate a permutation. A valid permutation will map each element in the input to a unique element in the output.
backwards :: forall (n :: Nat). KnownNat n => Permutation n Source #
Permutation generated by reversing the order of the elements.