Create Data.Permutation

This commit is contained in:
Kiana Sheibani 2022-05-11 23:36:31 -04:00
parent c44fef3c94
commit 55d304c734
Signed by: toki
GPG key ID: 6CB106C25E86A9F7

26
src/Data/Permutation.idr Normal file
View file

@ -0,0 +1,26 @@
module Data.Permutation
import Data.Vect
%default total
public export
Permutation : Nat -> Type
Permutation n = Vect n (Fin n)
public export
identity : {n : _} -> Permutation n
identity {n=Z} = []
identity {n=S n} = FZ :: map FS identity
public export
reversed : {n : _} -> Permutation n
reversed {n=Z} = []
reversed {n=S n} = last :: map weaken reversed
public export
permuteVect : Permutation n -> Vect n a -> Vect n a
permuteVect p v = map (\i => index i v) p