ܙӔb      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`a  experimental%Patrick Perry <patperry@stanford.edu>bcdefghijklmnopqrsbdfghijklmnopqrsbdfghijklmnopqrs  experimental%Patrick Perry <patperry@stanford.edu>5A mutable permutation that can be manipulated in the t monad. The  type argument s( is the state variable argument for the t type. u%The immutable permutation data type. # Internally, a permutation of size n is stored as an  0-based array of n v/s. The permutation represents a reordering of  the integers  0, ..., (n-1)&. The permutation sents the value p[i] to  i. w!Get the size of the permutation. (Get a list of the permutation elements. xyz{|}~uwxyz{|}~uuwwxyz{|}~  experimental%Patrick Perry <patperry@stanford.edu> 5A mutable permutation that can be manipulated in the  monad.   experimental%Patrick Perry <patperry@stanford.edu>(IClass for representing a mutable permutation. The type is parameterized  over the type of the monad, m+, in which the mutable permutation will be  manipulated. Get the size of a permutation. 9Create a new permutation initialized to be the identity. 5Allocate a new permutation but do not initialize it. FGet a lazy list of the permutation elements. The laziness makes this C function slightly dangerous if you are modifying the permutation. =Set all the values of a permutation from a list of elements. 3Construct a permutation from a list of elements.  newListPermute n is creates a permutation of size n with  the ith element equal to is !! i$. For the permutation to be valid,  the list is must have length n and contain the indices 0..(n-1)  exactly once each. .Construct a permutation from a list of swaps.  newSwapsPermute n ss creates a permutation of size n given a  sequence of swaps.  If ss is [(i0,j0), (i1,j1), ..., (ik,jk)], the  sequence of swaps is  i0 <-> j0, then  i1 <-> j1, and so on until  ik <-> jk. 0Construct a new permutation by copying another. copyPermute dst src( copies the elements of the permutation src  into the permutation dst+. The two permutations must have the same  size. #Set a permutation to the identity.  getElem p i gets the value of the ith element of the permutation  p . The index i must be in the range 0..(n-1), where n is the  size of the permutation.  setElem p i x sets the value of the ith element of the permutation  p . The index i must be in the range 0..(n-1), where n is the  size of the permutation. swapElems p i j exchanges the ith and jth elements of the  permutation p. FReturns whether or not the permutation is valid. For it to be valid,  the numbers  0,...,(n-1), must all appear exactly once in the stored  values p[0] ,...,p[n-1]. (Compute the inverse of a permutation. 4Set one permutation to be the inverse of another.  copyInverse inv p computes the inverse of p and stores it in inv. / The two permutations must have the same size. HAdvance a permutation to the next permutation in lexicogrphic order and  return True4. If no further permutaitons are available, return False and L leave the permutation unmodified. Starting with the idendity permutation  and repeatedly calling setNext- will iterate through all permutations of a  given size. FStep backwards to the previous permutation in lexicographic order and  return True/. If there is no previous permutation, return False and # leave the permutation unmodified. EGet a lazy list of swaps equivalent to the permutation. A result of  ![ (i0,j0), (i1,j1), ..., (ik,jk) ] means swap i0 <-> j0,  then i1 <-> j1, and so on until ik <-> jk. The laziness makes this C function slightly dangerous if you are modifying the permutation. !EGet a lazy list of swaps equivalent to the inverse of a permutation. "3Convert a mutable permutation to an immutable one. #3Convert an immutable permutation to a mutable one. $ getSort n xs sorts the first n elements of xs and returns a  permutation which transforms xs% into sorted order. The results are  undefined if n is greater than the length of xs. This is a special  case of %. %& getOrder n xs2 returns a permutation which rearranges the first n  elements of xs4 into ascending order. The results are undefined if n is  greater than the length of xs. This is a special case of '. '( getRank n xs< eturns a permutation, the inverse of which rearranges the  first n elements of xs2 into ascending order. The returned permutation,  p, has the property that p[i] is the rank of the ith element of xs.  The results are undefined if n is greater than the length of xs.  This is a special case of ). )$  !"#$%&'()$  !$%&'()"#$    !"#$%&'() experimental%Patrick Perry <patperry@stanford.edu>*KA safe way to create and work with a mutable permutation before returning G an immutable one for later perusal. This function avoids copying the N permutation before returning it - it uses unsafeFreeze internally, but this 0 wrapper is a safe interface to that function. &  !"#$%&'()*** experimental%Patrick Perry <patperry@stanford.edu>%  !"#$%&'() experimental%Patrick Perry <patperry@stanford.edu>+5Construct an identity permutation of the given size. ,3Construct a permutation from a list of elements.  listPermute n is creates a permutation of size n with  the ith element equal to is !! i$. For the permutation to be valid,  the list is must have length n and contain the indices 0..(n-1)  exactly once each. -.Construct a permutation from a list of swaps.  swapsPermute n ss creats a permutation of size n given by a  sequence of swaps.  If ss is [(i0,j0), (i1,j1), ..., (ik,jk)], the  sequence of swaps is  i0 <-> j0, then  i1 <-> j1, and so on until  ik <-> jk. .at p i gets the value of the ith element of the permutation  p . The index i must be in the range 0..(n-1), where n is the  size of the permutation. /!Get the inverse of a permutation 07Return the next permutation in lexicographic order, or Nothing if L there are no further permutations. Starting with the identity permutation L and repeatedly calling this function will iterate through all permutations  of a given order. 1;Return the previous permutation in lexicographic order, or Nothing  if no such permutation exists. 2@Get a list of swaps equivalent to the permutation. A result of  ![ (i0,j0), (i1,j1), ..., (ik,jk) ] means swap i0 <-> j0,  then i1 <-> j1, and so on until ik <-> jk. 3>Get a list of swaps equivalent to the inverse of permutation. 4 sort n xs sorts the first n elements of xs and returns a  permutation which transforms xs% into sorted order. The results are  undefined if n is greater than the length of xs. This is a special  case of 5. 56 order n xs2 returns a permutation which rearranges the first n  elements of xs4 into ascending order. The results are undefined if n is  greater than the length of xs. This is a special case of 7. 78 rank n xs< eturns a permutation, the inverse of which rearranges the  first n elements of xs2 into ascending order. The returned permutation,  p, has the property that p[i] is the rank of the ith element of xs.  The results are undefined if n is greater than the length of xs.  This is a special case of 9. 9+,-./0123456789+,-./0123456789+,-./0123456789  experimental%Patrick Perry <patperry@stanford.edu>:5A mutable combination that can be manipulated in the t monad. The  type argument s( is the state variable argument for the t type. ;<The immutable combination data type. A way of representing k  unordered outcomes from n% possiblities. The possibilites are  represented as the indices  0, ..., n-1, and the outcomes are  given as a subset of size k). The subset is stored with the indices  in ascending order. <=Get the number of outcomes, k. >!Get the number of possibilities, n. ?Get a list of the k outcomes. :;<=>?:;<=>?  experimental%Patrick Perry <patperry@stanford.edu>@5A mutable combination that can be manipulated in the  monad. @@ experimental%Patrick Perry <patperry@stanford.edu>AIClass for representing a mutable combination. The type is parameterized  over the type of the monad, m+, in which the mutable combination will be  manipulated. B!Get the number of possibilities, n in the combination. CGet the number of outcomes, k in the combination. D newChoose n k creates a new combination of k outcomes from n ( possibilites initialized to the subset { 0, ..., k-1 }. E newChoose n k allocates a new combination of k outcomes from  n+ possibilities but does not initialize it. FGHFGet a lazy list of the combination elements. The laziness makes this C function slightly dangerous if you are modifying the combination. I=Set all the values of a combination from a list of elements. JKL3Construct a combination from a list of elements.  newListChoose n k is creates a combination of k outcomes from n ' possibilities initialized to have the ith element equal to is !! i. I For the combination to be valid, the elements must all be unique, they < must be in sorted order, and they all must be in the range 0 .. n-1. MN0Construct a new combination by copying another. OcopyChoose dst src( copies the elements of the combination src  into the combination dst+. The two combinations must have the same  size. P6Set a combination to be the first subset of its size. Q getElem c i gets the value of the ith element of the combination  c . The index i must be in the range 0..k-1, where n is the  size of the combination. R setElem c i x sets the value of the ith element of the combination  c . The index i must be in the range 0..k-1, where k is the  size of the combination. SFReturns whether or not the combination is valid. For it to be valid, I the elements must all be unique, they must be in sorted order, and they  all must be in the range 0 .. n-1, where n is the number of ! possibilies in the combination. T(Compute the complement of a combination UGReturn a lazy list of the elements in the complement of a combination. # If the combination is a subset of k outcomes from n possibilities, then 0 the returned list will be sorted and of length n-k. L Due to the laziness, you should be careful when using this function if you % are also modifying the combination. VCAdvance a combination to the next in lexicogrphic order and return True. 3 If no further combinations are available, return False and leave the ( combination unmodified. Starting with  [ 0 .. k-1 ] and repeatedly  calling setNext* will iterate through all subsets of size k. WFStep backwards to the previous combination in lexicographic order and  return True/. If there is no previous combination, return False and # leave the combination unmodified. X3Convert a mutable combination to an immutable one. Y3Convert an immutable combination to a mutable one. ABCDEFGHIJKLMNOPQRSTUVWXYABCDEFGHIJKLNOPQRSTUVWXYMA BCDEFGHIJKBCDEFGHIJKLMNOPQRSTUVWXY experimental%Patrick Perry <patperry@stanford.edu>ZKA safe way to create and work with a mutable combination before returning G an immutable one for later perusal. This function avoids copying the N combination before returning it - it uses unsafeFreeze internally, but this 0 wrapper is a safe interface to that function. :ABCDEFGHIJKLMNOPQRSTUVWXYZ:ZZ experimental%Patrick Perry <patperry@stanford.edu>@ABCDEFGHIJKLMNOPQRSTUVWXY@ experimental%Patrick Perry <patperry@stanford.edu>[ choose n k" returns the first combination of k outcomes from n ! possibilites, namely the subset { 0, ..., k-1 }. \3Construct a combination from a list of elements.  listChoose n k is creates a combination of k outcomes from n ' possibilities initialized to have the ith element equal to is !! i. I For the combination to be valid, the elements must all be unique, they < must be in sorted order, and they all must be in the range 0 .. n-1. ]at c i gets the value of the ith element of the combination  c . The index i must be in the range 0..(k-1), where k is the  size of the combination. ^!Get the inverse of a combination _?Get a list of the elements in the complement of a combination. # If the combination is a subset of k outcomes from n possibilities, then 0 the returned list will be sorted and of length n-k. `7Return the next combination in lexicographic order, or Nothing if I there are no further combinations. Starting with the first combination L and repeatedly calling this function will iterate through all combinations  of a given order. a;Return the previous combination in lexicographic order, or Nothing  if such combination exists. ;<=>?[\]^_`a ;[\]<>=?^_`a[\]^_`a       !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFG H I   J  KLMNOPQRST&')UV,-01WXY<Z[>? \ \ ] ] ^   _ ` a b c d e f g  hij klm  n o p q r s t u v w xkly  z { | } ~   H I K permutation-0.3Data.Permute.ST Data.PermuteData.Permute.IOData.Permute.MPermuteData.Choose.ST Data.ChooseData.Choose.IOData.Choose.MChoose Data.IntArrayData.Permute.BaseData.Permute.IOBaseData.Choose.BaseData.Choose.IOBase STPermutePermuteunsafeAtsizeelems IOPermuteMPermutegetSize newPermute newPermute_ unsafeGetElem unsafeSetElemunsafeSwapElemsgetElemssetElems unsafeFreeze unsafeThawnewListPermuteunsafeNewListPermutenewSwapsPermuteunsafeNewSwapsPermutenewCopyPermute copyPermute setIdentitygetElemsetElem swapElemsisValid getInverse copyInversesetNextsetPrevgetSwaps getInvSwapsfreezethawgetSort getSortBygetOrder getOrderBygetRank getRankBy runSTPermutepermute listPermute swapsPermuteatinversenextprevswapsinvSwapssortsortByorderorderByrankrankBySTChooseChoosepossibleIOChooseMChoose getPossible newChoose newChoose_ newListChooseunsafeNewListChoose newCopyChoose copyChoosesetFirst getComplement getComplElems runSTChoosechoose listChoose complement complElems STIntArrayIntArray numElements newArray_sameSTIntArraynumElementsSTIntArraygetNumElements unsafeRead unsafeWrite unsafeSwap readElems writeElemsbaseGHC.STSTghc-prim GHC.TypesIntgetSizeSTPermute sizeSTPermute newSTPermute newSTPermute_unsafeGetElemSTPermuteunsafeSetElemSTPermuteunsafeSwapElemsSTPermutegetElemsSTPermutesetElemsSTPermuteunsafeFreezeSTPermuteunsafeThawSTPermuteIO newIOPermute newIOPermute_getSizeIOPermute sizeIOPermuteunsafeGetElemIOPermuteunsafeSetElemIOPermuteunsafeSwapElemsIOPermutegetElemsIOPermutesetElemsIOPermuteunsafeFreezeIOPermuteunsafeThawIOPermuteunsafeInterleaveMnewSwapsPermuteHelp setNextBy getSwapsHelp nextPrevHelpgetSizeSTChoose sizeSTChoosegetPossibleSTChoosepossibleSTChoose newSTChoose newSTChoose_unsafeGetElemSTChooseunsafeSetElemSTChoosegetElemsSTChoosesetElemsSTChooseunsafeFreezeSTChooseunsafeThawSTChoose newIOChoose newIOChoose_getPossibleIOChoosepossibleIOChoosegetSizeIOChoose sizeIOChooseunsafeGetElemIOChooseunsafeSetElemIOChoosegetElemsIOChoosesetElemsIOChooseunsafeFreezeIOChooseunsafeThawIOChoose