packages feed

phonetic-languages-permutations-array 0.3.4.0 → 0.4.0.0

raw patch · 11 files changed

+259/−233 lines, 11 filesdep ~basedep ~subGPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base, subG

API changes (from Hackage documentation)

- Phonetic.Languages.Permutations.Arr: genPermutations :: Int -> Array Int [Int]
- Phonetic.Languages.Permutations.Arr: genPermutationsArr :: Array Int (Array Int [Int])
- Phonetic.Languages.Permutations.Arr: genPermutationsArrL :: Array Int [Array Int Int]
- Phonetic.Languages.Permutations.Arr: genPermutationsL :: Int -> [Array Int Int]
- Phonetic.Languages.Permutations.Arr: universalSetGL :: (Eq a, Foldable t, InsertLeft t a, Monoid (t a), Monoid (t (t a))) => t a -> t (t a) -> (t a -> [a]) -> (t (t a) -> [[a]]) -> [Array Int Int] -> Array Int [a] -> [[a]]
- Phonetic.Languages.Permutations.ArrMini: genPairwisePermutations :: Int -> Array Int [Int]
- Phonetic.Languages.Permutations.ArrMini: genPairwisePermutationsArr :: Array Int (Array Int [Int])
- Phonetic.Languages.Permutations.ArrMini: genPairwisePermutationsArrL :: Array Int [Array Int Int]
- Phonetic.Languages.Permutations.ArrMini: genPairwisePermutationsArrLN :: Int -> Array Int [Array Int Int]
- Phonetic.Languages.Permutations.ArrMini: genPairwisePermutationsArrN :: Int -> Array Int (Array Int [Int])
- Phonetic.Languages.Permutations.ArrMini: genPairwisePermutationsL :: [Array Int Int]
- Phonetic.Languages.Permutations.ArrMini: genPairwisePermutationsLN :: Int -> [Array Int Int]
- Phonetic.Languages.Permutations.ArrMini: pairsSwapP :: [Int] -> [[Int]]
- Phonetic.Languages.Permutations.ArrMini1: genElementaryPermutations1 :: Int -> Array Int [Int]
- Phonetic.Languages.Permutations.ArrMini1: genElementaryPermutationsArr1 :: Array Int (Array Int [Int])
- Phonetic.Languages.Permutations.ArrMini1: genElementaryPermutationsArrL1 :: Array Int [Array Int Int]
- Phonetic.Languages.Permutations.ArrMini1: genElementaryPermutationsArrLN1 :: Int -> Array Int [Array Int Int]
- Phonetic.Languages.Permutations.ArrMini1: genElementaryPermutationsArrN1 :: Int -> Array Int (Array Int [Int])
- Phonetic.Languages.Permutations.ArrMini1: genElementaryPermutationsL1 :: [Array Int Int]
- Phonetic.Languages.Permutations.ArrMini1: genElementaryPermutationsLN1 :: Int -> [Array Int Int]
- Phonetic.Languages.Permutations.ArrMini1: pairsSwapP1 :: [Int] -> [[Int]]
- Phonetic.Languages.Permutations.Represent: P :: Int -> PermutationsType
- Phonetic.Languages.Permutations.Represent: bTransform2Perms :: [String] -> PermutationsType
- Phonetic.Languages.Permutations.Represent: data PermutationsType
- Phonetic.Languages.Permutations.Represent: instance GHC.Classes.Eq Phonetic.Languages.Permutations.Represent.PermutationsType
- Phonetic.Languages.Permutations.Represent: instance GHC.Classes.Ord Phonetic.Languages.Permutations.Represent.PermutationsType
- Phonetic.Languages.Permutations.Represent: instance GHC.Show.Show Phonetic.Languages.Permutations.Represent.PermutationsType
+ Phladiprelio.PermutationsArr: genPermutations :: Int -> Array Int [Int]
+ Phladiprelio.PermutationsArr: genPermutationsArr :: Array Int (Array Int [Int])
+ Phladiprelio.PermutationsArr: genPermutationsArrL :: Array Int [Array Int Int]
+ Phladiprelio.PermutationsArr: genPermutationsL :: Int -> [Array Int Int]
+ Phladiprelio.PermutationsArr: universalSetGL :: (Eq a, Foldable t, InsertLeft t a, Monoid (t a), Monoid (t (t a))) => t a -> t (t a) -> (t a -> [a]) -> (t (t a) -> [[a]]) -> [Array Int Int] -> Array Int [a] -> [[a]]
+ Phladiprelio.PermutationsArrMini: genPairwisePermutations :: Int -> Array Int [Int]
+ Phladiprelio.PermutationsArrMini: genPairwisePermutationsArr :: Array Int (Array Int [Int])
+ Phladiprelio.PermutationsArrMini: genPairwisePermutationsArrL :: Array Int [Array Int Int]
+ Phladiprelio.PermutationsArrMini: genPairwisePermutationsArrLN :: Int -> Array Int [Array Int Int]
+ Phladiprelio.PermutationsArrMini: genPairwisePermutationsArrN :: Int -> Array Int (Array Int [Int])
+ Phladiprelio.PermutationsArrMini: genPairwisePermutationsL :: [Array Int Int]
+ Phladiprelio.PermutationsArrMini: genPairwisePermutationsLN :: Int -> [Array Int Int]
+ Phladiprelio.PermutationsArrMini: pairsSwapP :: [Int] -> [[Int]]
+ Phladiprelio.PermutationsArrMini1: genElementaryPermutations1 :: Int -> Array Int [Int]
+ Phladiprelio.PermutationsArrMini1: genElementaryPermutationsArr1 :: Array Int (Array Int [Int])
+ Phladiprelio.PermutationsArrMini1: genElementaryPermutationsArrL1 :: Array Int [Array Int Int]
+ Phladiprelio.PermutationsArrMini1: genElementaryPermutationsArrLN1 :: Int -> Array Int [Array Int Int]
+ Phladiprelio.PermutationsArrMini1: genElementaryPermutationsArrN1 :: Int -> Array Int (Array Int [Int])
+ Phladiprelio.PermutationsArrMini1: genElementaryPermutationsL1 :: [Array Int Int]
+ Phladiprelio.PermutationsArrMini1: genElementaryPermutationsLN1 :: Int -> [Array Int Int]
+ Phladiprelio.PermutationsArrMini1: pairsSwapP1 :: [Int] -> [[Int]]
+ Phladiprelio.PermutationsRepresent: P :: Int -> PermutationsType
+ Phladiprelio.PermutationsRepresent: bTransform2Perms :: [String] -> PermutationsType
+ Phladiprelio.PermutationsRepresent: data PermutationsType
+ Phladiprelio.PermutationsRepresent: instance GHC.Classes.Eq Phladiprelio.PermutationsRepresent.PermutationsType
+ Phladiprelio.PermutationsRepresent: instance GHC.Classes.Ord Phladiprelio.PermutationsRepresent.PermutationsType
+ Phladiprelio.PermutationsRepresent: instance GHC.Show.Show Phladiprelio.PermutationsRepresent.PermutationsType

Files

CHANGELOG.md view
@@ -35,3 +35,9 @@ ## 0.3.4.0 -- 2022-03-24  * Third version revised E. Updated the dependency boundaries to support the latest GHC and Cabal.++## 0.4.0.0 -- 2023-01-30++* Fourth version. Switched to NoImplicitPrelude extension. Some minor code improvements. +Changed the names of the modules. Updated the dependencies boundaries.+
LICENSE view
@@ -1,4 +1,4 @@-Copyright (c) 2020-2022 OleksandrZhabenko+Copyright (c) 2020-2023 OleksandrZhabenko  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the
+ Phladiprelio/PermutationsArr.hs view
@@ -0,0 +1,60 @@+{-# LANGUAGE NoImplicitPrelude #-}++-- |+-- Module      :  Phladiprelio.PermutationsArr+-- Copyright   :  (c) OleksandrZhabenko 2020-2023+-- License     :  MIT+-- Stability   :  Experimental+-- Maintainer  :  oleksandr.zhabenko@yahoo.com+--+-- Permutations and universal set functions for the phonetic-languages series of packages+-- (PhLADiPreLiO-related). This module uses no vectors, but instead uses arrays.++module Phladiprelio.PermutationsArr (+  universalSetGL+  , genPermutations+  , genPermutationsArr+  , genPermutationsL+  , genPermutationsArrL+) where++import GHC.List+import GHC.Num ((*), (-))+import GHC.Base+import GHC.Arr+import qualified Data.List as L (permutations)+import Data.SubG+import qualified Data.Foldable as F (Foldable,concat,foldr',foldl')+import Data.Monoid++-- | A key point of the evaluation -- the universal set of the task represented as a @[[a]]@.+universalSetGL ::+  (Eq a, F.Foldable t, InsertLeft t a, Monoid (t a), Monoid (t (t a))) => t a+  -> t (t a)+  -> (t a -> [a]) -- ^ The function that is used internally to convert to the @[a]@ so that the function can process further the permutations+  -> ((t (t a)) -> [[a]]) -- ^ The function that is used internally to convert to the needed representation so that the function can process further+  -> [Array Int Int] -- ^ The list of permutations of 'Int' indices starting from 0 and up to n (n is probably less than 7).+  -> Array Int [a]+  -> [[a]]+universalSetGL ts uss f1 f2 permsL baseArr = map (F.concat . F.foldr' (:) [] . (f1 ts:) . (`mappend` f2 uss) . elems . amap (unsafeAt baseArr)) permsL+{-# INLINE universalSetGL #-}++-- | One of the popular examples:  realization of the factorial function using 'F.foldl''. Is taken from some+-- teaching material.+factorial n = F.foldl' (*) 1 [1..n]++genPermutations :: Int -> Array Int [Int]+genPermutations n = listArray (0,factorial n - 1) . L.permutations . take n $ [0..]+{-# INLINE genPermutations #-}++genPermutationsArr :: Array Int (Array Int [Int])+genPermutationsArr = amap genPermutations . listArray (0,5) $ [2..7]+{-# INLINE genPermutationsArr #-}++genPermutationsL :: Int -> [Array Int Int]+genPermutationsL n = map (\xs -> listArray (0,n - 1) xs) . L.permutations . take n $ [0..]+{-# INLINE genPermutationsL #-}++genPermutationsArrL :: Array Int [Array Int Int]+genPermutationsArrL = amap genPermutationsL . listArray (0,5) $ [2..7]+{-# INLINE genPermutationsArrL #-}
+ Phladiprelio/PermutationsArrMini.hs view
@@ -0,0 +1,73 @@+{-# LANGUAGE NoImplicitPrelude #-}++-- |+-- Module      :  Phladiprelio.PermutationsArrMini+-- Copyright   :  (c) OleksandrZhabenko 2021-2023+-- License     :  MIT+-- Stability   :  Experimental+-- Maintainer  :  oleksandr.zhabenko@yahoo.com+--+-- Special permutations functions for the phonetic-languages series of packages. This+-- module uses no vectors, but instead uses arrays.++module Phladiprelio.PermutationsArrMini (+  genPairwisePermutations+  , pairsSwapP+  , genPairwisePermutationsArrN+  , genPairwisePermutationsArr+  , genPairwisePermutationsLN+  , genPairwisePermutationsL+  , genPairwisePermutationsArrLN+  , genPairwisePermutationsArrL+) where++import Data.Bits (shiftR)+import GHC.Base+import GHC.Num+import GHC.List+import GHC.Arr++genPairwisePermutations :: Int -> Array Int [Int]+genPairwisePermutations n = listArray (0, shiftR (n*(n-1)) 1) . pairsSwapP . take n $ [0..]+{-# INLINE genPairwisePermutations #-}++pairsSwapP :: [Int] -> [[Int]]+pairsSwapP xs = xs:[swap2Ls k m xs | k <- xs, m <- xs , k < m]+{-# INLINABLE pairsSwapP #-}++-- | The first two arguments are considered not equal, though it is not checked.+swap2ns :: Int -> Int -> Int -> Int+swap2ns k m n+ | n /= k = if n /= m then n else k+ | otherwise = m+{-# INLINE swap2ns #-}++swap2Ls :: Int -> Int -> [Int] -> [Int]+swap2Ls k m = map (swap2ns k m)+{-# INLINE swap2Ls #-}++genPairwisePermutationsArrN :: Int -> Array Int (Array Int [Int])+genPairwisePermutationsArrN n = amap genPairwisePermutations . listArray (0,n - 2) $ [2..n]+{-# INLINE genPairwisePermutationsArrN #-}++genPairwisePermutationsArr :: Array Int (Array Int [Int])+genPairwisePermutationsArr = genPairwisePermutationsArrN 10+{-# INLINE genPairwisePermutationsArr #-}++genPairwisePermutationsLN :: Int -> [Array Int Int]+genPairwisePermutationsLN n = map (\xs -> listArray (0,n - 1) xs) . pairsSwapP . take n $ [0..]+{-# INLINE genPairwisePermutationsLN #-}++genPairwisePermutationsL :: [Array Int Int]+genPairwisePermutationsL = genPairwisePermutationsLN 10+{-# INLINE genPairwisePermutationsL #-}++genPairwisePermutationsArrLN :: Int -> Array Int [Array Int Int]+genPairwisePermutationsArrLN n = amap genPairwisePermutationsLN . listArray (0,n - 2) $ [2..n]+{-# INLINE genPairwisePermutationsArrLN #-}++genPairwisePermutationsArrL :: Array Int [Array Int Int]+genPairwisePermutationsArrL = genPairwisePermutationsArrLN 10+{-# INLINE genPairwisePermutationsArrL #-}++
+ Phladiprelio/PermutationsArrMini1.hs view
@@ -0,0 +1,84 @@+{-# LANGUAGE MultiWayIf #-}+{-# LANGUAGE NoImplicitPrelude #-}+++-- |+-- Module      :  Phladiprelio.PermutationsArrMini1+-- Copyright   :  (c) OleksandrZhabenko 2022-2023+-- License     :  MIT+-- Stability   :  Experimental+-- Maintainer  :  oleksandr.zhabenko@yahoo.com+--+-- Special permutations functions for the phonetic-languages series of packages. This+-- module uses no vectors, but instead uses arrays.++module Phladiprelio.PermutationsArrMini1 (+  genElementaryPermutations1+  , pairsSwapP1+  , genElementaryPermutationsArrN1+  , genElementaryPermutationsArr1+  , genElementaryPermutationsLN1+  , genElementaryPermutationsL1+  , genElementaryPermutationsArrLN1+  , genElementaryPermutationsArrL1+) where++import GHC.Base+import GHC.Arr+import GHC.List+import GHC.Num ((-), (+), abs)++genElementaryPermutations1 :: Int -> Array Int [Int]+genElementaryPermutations1 n = listArray (0,l-1) xs+ where xs = pairsSwapP1 . take n $ [0..]+       l = length xs+{-# INLINE genElementaryPermutations1 #-}++pairsSwapP1 :: [Int] -> [[Int]]+pairsSwapP1 xs = xs:[swap2Ls1 k m xs | k <- xs, m <- xs , abs (k - m) > 1] `mappend` [swap2Ls1 k (k - 1) xs | k <- drop 1 xs ]+{-# INLINABLE pairsSwapP1 #-}++-- | The first two arguments are considered not equal and all three of the arguments are considered greater or equal to 0, though it is not checked.+swap2ns1 :: Int -> Int -> Int -> Int+swap2ns1 k n m+ | n > k =+    if+      | m < k -> m+      | m > n -> m+      | m < n -> m + 1+      | otherwise -> k+ | otherwise =+     if+       | m > k -> m+       | m < n -> m+       | m > n -> m - 1+       | otherwise -> k+{-# INLINE swap2ns1 #-}++swap2Ls1 :: Int -> Int -> [Int] -> [Int]+swap2Ls1 k m = map (swap2ns1 k m)+{-# INLINE swap2Ls1 #-}++genElementaryPermutationsArrN1 :: Int -> Array Int (Array Int [Int])+genElementaryPermutationsArrN1 n = amap genElementaryPermutations1 . listArray (0,n - 2) $ [2..n]+{-# INLINE genElementaryPermutationsArrN1 #-}++genElementaryPermutationsArr1 :: Array Int (Array Int [Int])+genElementaryPermutationsArr1 = genElementaryPermutationsArrN1 10+{-# INLINE genElementaryPermutationsArr1 #-}++genElementaryPermutationsLN1 :: Int -> [Array Int Int]+genElementaryPermutationsLN1 n = map (\xs -> listArray (0,n - 1) xs) . pairsSwapP1 . take n $ [0..]+{-# INLINE genElementaryPermutationsLN1 #-}++genElementaryPermutationsL1 :: [Array Int Int]+genElementaryPermutationsL1 = genElementaryPermutationsLN1 10+{-# INLINE genElementaryPermutationsL1 #-}++genElementaryPermutationsArrLN1 :: Int -> Array Int [Array Int Int]+genElementaryPermutationsArrLN1 n = amap genElementaryPermutationsLN1 . listArray (0,n - 2) $ [2..n]+{-# INLINE genElementaryPermutationsArrLN1 #-}++genElementaryPermutationsArrL1 :: Array Int [Array Int Int]+genElementaryPermutationsArrL1 = genElementaryPermutationsArrLN1 10+{-# INLINE genElementaryPermutationsArrL1 #-}
+ Phladiprelio/PermutationsRepresent.hs view
@@ -0,0 +1,30 @@+{-# LANGUAGE NoImplicitPrelude #-}++-- |+-- Module      :  Phladiprelio.PermutationsRepresent+-- Copyright   :  (c) OleksandrZhabenko 2022-2023+-- License     :  MIT+-- Stability   :  Experimental+-- Maintainer  :  oleksandr.zhabenko@yahoo.com+--+-- Permutations data type to mark the needed permutations type from the other modules.++module Phladiprelio.PermutationsRepresent (+  PermutationsType(..)+  , bTransform2Perms+) where++import GHC.Base+import Text.Show+--import Data.Monoid++data PermutationsType = P Int deriving (Eq, Ord)++instance Show PermutationsType where+  show (P x) = "+p " `mappend` show x++bTransform2Perms :: [String] -> PermutationsType+bTransform2Perms ys+ | ys == ["1"] = P 1+ | ys == ["2"] = P 2+ | otherwise = P 0
− Phonetic/Languages/Permutations/Arr.hs
@@ -1,55 +0,0 @@--- |--- Module      :  Phonetic.Languages.Permutations.Arr--- Copyright   :  (c) OleksandrZhabenko 2020-2021--- License     :  MIT--- Stability   :  Experimental--- Maintainer  :  olexandr543@yahoo.com------ Permutations and universal set functions for the phonetic-languages series of packages. This--- module uses no vectors, but instead uses arrays.--module Phonetic.Languages.Permutations.Arr (-  universalSetGL-  , genPermutations-  , genPermutationsArr-  , genPermutationsL-  , genPermutationsArrL-) where--import GHC.Arr-import qualified Data.List as L (permutations)-import Data.SubG-import qualified Data.Foldable as F (concat,foldr',foldl')-import Data.Monoid---- | A key point of the evaluation -- the universal set of the task represented as a @[[a]]@.-universalSetGL ::-  (Eq a, Foldable t, InsertLeft t a, Monoid (t a), Monoid (t (t a))) => t a-  -> t (t a)-  -> (t a -> [a]) -- ^ The function that is used internally to convert to the @[a]@ so that the function can process further the permutations-  -> ((t (t a)) -> [[a]]) -- ^ The function that is used internally to convert to the needed representation so that the function can process further-  -> [Array Int Int] -- ^ The list of permutations of 'Int' indices starting from 0 and up to n (n is probably less than 7).-  -> Array Int [a]-  -> [[a]]-universalSetGL ts uss f1 f2 permsL baseArr = map (F.concat . F.foldr' (:) [] . (f1 ts:) . (`mappend` f2 uss) . elems . amap (unsafeAt baseArr)) permsL-{-# INLINE universalSetGL #-}---- | One of the popular examples:  realization of the factorial function using 'F.foldl''. Is taken from some--- teaching material.-factorial n = F.foldl' (*) 1 [1..n]--genPermutations :: Int -> Array Int [Int]-genPermutations n = listArray (0,factorial n - 1) . L.permutations . take n $ [0..]-{-# INLINE genPermutations #-}--genPermutationsArr :: Array Int (Array Int [Int])-genPermutationsArr = amap genPermutations . listArray (0,5) $ [2..7]-{-# INLINE genPermutationsArr #-}--genPermutationsL :: Int -> [Array Int Int]-genPermutationsL n = map (\xs -> listArray (0,n - 1) xs) . L.permutations . take n $ [0..]-{-# INLINE genPermutationsL #-}--genPermutationsArrL :: Array Int [Array Int Int]-genPermutationsArrL = amap genPermutationsL . listArray (0,5) $ [2..7]-{-# INLINE genPermutationsArrL #-}
− Phonetic/Languages/Permutations/ArrMini.hs
@@ -1,67 +0,0 @@--- |--- Module      :  Phonetic.Languages.Permutations.ArrMini--- Copyright   :  (c) OleksandrZhabenko 2021--- License     :  MIT--- Stability   :  Experimental--- Maintainer  :  olexandr543@yahoo.com------ Special permutations functions for the phonetic-languages series of packages. This--- module uses no vectors, but instead uses arrays.--module Phonetic.Languages.Permutations.ArrMini (-  genPairwisePermutations-  , pairsSwapP-  , genPairwisePermutationsArrN-  , genPairwisePermutationsArr-  , genPairwisePermutationsLN-  , genPairwisePermutationsL-  , genPairwisePermutationsArrLN-  , genPairwisePermutationsArrL-) where--import GHC.Arr--genPairwisePermutations :: Int -> Array Int [Int]-genPairwisePermutations n = listArray (0,(n*(n-1)) `quot` 2) . pairsSwapP . take n $ [0..]-{-# INLINE genPairwisePermutations #-}--pairsSwapP :: [Int] -> [[Int]]-pairsSwapP xs = xs:[swap2Ls k m xs | k <- xs, m <- xs , k < m]-{-# INLINABLE pairsSwapP #-}---- | The first two arguments are considered not equal, though it is not checked.-swap2ns :: Int -> Int -> Int -> Int-swap2ns k m n- | n /= k = if n /= m then n else k- | otherwise = m-{-# INLINE swap2ns #-}--swap2Ls :: Int -> Int -> [Int] -> [Int]-swap2Ls k m = map (swap2ns k m)-{-# INLINE swap2Ls #-}--genPairwisePermutationsArrN :: Int -> Array Int (Array Int [Int])-genPairwisePermutationsArrN n = amap genPairwisePermutations . listArray (0,n - 2) $ [2..n]-{-# INLINE genPairwisePermutationsArrN #-}--genPairwisePermutationsArr :: Array Int (Array Int [Int])-genPairwisePermutationsArr = genPairwisePermutationsArrN 10-{-# INLINE genPairwisePermutationsArr #-}--genPairwisePermutationsLN :: Int -> [Array Int Int]-genPairwisePermutationsLN n = map (\xs -> listArray (0,n - 1) xs) . pairsSwapP . take n $ [0..]-{-# INLINE genPairwisePermutationsLN #-}--genPairwisePermutationsL :: [Array Int Int]-genPairwisePermutationsL = genPairwisePermutationsLN 10-{-# INLINE genPairwisePermutationsL #-}--genPairwisePermutationsArrLN :: Int -> Array Int [Array Int Int]-genPairwisePermutationsArrLN n = amap genPairwisePermutationsLN . listArray (0,n - 2) $ [2..n]-{-# INLINE genPairwisePermutationsArrLN #-}--genPairwisePermutationsArrL :: Array Int [Array Int Int]-genPairwisePermutationsArrL = genPairwisePermutationsArrLN 10-{-# INLINE genPairwisePermutationsArrL #-}--
− Phonetic/Languages/Permutations/ArrMini1.hs
@@ -1,79 +0,0 @@-{-# LANGUAGE MultiWayIf #-}---- |--- Module      :  Phonetic.Languages.Permutations.ArrMini1--- Copyright   :  (c) OleksandrZhabenko 2022--- License     :  MIT--- Stability   :  Experimental--- Maintainer  :  olexandr543@yahoo.com------ Special permutations functions for the phonetic-languages series of packages. This--- module uses no vectors, but instead uses arrays.--module Phonetic.Languages.Permutations.ArrMini1 (-  genElementaryPermutations1-  , pairsSwapP1-  , genElementaryPermutationsArrN1-  , genElementaryPermutationsArr1-  , genElementaryPermutationsLN1-  , genElementaryPermutationsL1-  , genElementaryPermutationsArrLN1-  , genElementaryPermutationsArrL1-) where--import GHC.Arr--genElementaryPermutations1 :: Int -> Array Int [Int]-genElementaryPermutations1 n = listArray (0,l-1) xs- where xs = pairsSwapP1 . take n $ [0..]-       l = length xs-{-# INLINE genElementaryPermutations1 #-}--pairsSwapP1 :: [Int] -> [[Int]]-pairsSwapP1 xs = xs:[swap2Ls1 k m xs | k <- xs, m <- xs , abs (k - m) > 1] `mappend` [swap2Ls1 k (k - 1) xs | k <- drop 1 xs ]-{-# INLINABLE pairsSwapP1 #-}---- | The first two arguments are considered not equal and all three of the arguments are considered greater or equal to 0, though it is not checked.-swap2ns1 :: Int -> Int -> Int -> Int-swap2ns1 k n m- | n > k =-    if-      | m < k -> m-      | m > n -> m-      | m >= k && m < n -> m + 1-      | otherwise -> k- | otherwise =-     if-       | m > k -> m-       | m < n -> m-       | m <= k && m > n -> m - 1-       | otherwise -> k-{-# INLINE swap2ns1 #-}--swap2Ls1 :: Int -> Int -> [Int] -> [Int]-swap2Ls1 k m = map (swap2ns1 k m)-{-# INLINE swap2Ls1 #-}--genElementaryPermutationsArrN1 :: Int -> Array Int (Array Int [Int])-genElementaryPermutationsArrN1 n = amap genElementaryPermutations1 . listArray (0,n - 2) $ [2..n]-{-# INLINE genElementaryPermutationsArrN1 #-}--genElementaryPermutationsArr1 :: Array Int (Array Int [Int])-genElementaryPermutationsArr1 = genElementaryPermutationsArrN1 10-{-# INLINE genElementaryPermutationsArr1 #-}--genElementaryPermutationsLN1 :: Int -> [Array Int Int]-genElementaryPermutationsLN1 n = map (\xs -> listArray (0,n - 1) xs) . pairsSwapP1 . take n $ [0..]-{-# INLINE genElementaryPermutationsLN1 #-}--genElementaryPermutationsL1 :: [Array Int Int]-genElementaryPermutationsL1 = genElementaryPermutationsLN1 10-{-# INLINE genElementaryPermutationsL1 #-}--genElementaryPermutationsArrLN1 :: Int -> Array Int [Array Int Int]-genElementaryPermutationsArrLN1 n = amap genElementaryPermutationsLN1 . listArray (0,n - 2) $ [2..n]-{-# INLINE genElementaryPermutationsArrLN1 #-}--genElementaryPermutationsArrL1 :: Array Int [Array Int Int]-genElementaryPermutationsArrL1 = genElementaryPermutationsArrLN1 10-{-# INLINE genElementaryPermutationsArrL1 #-}
− Phonetic/Languages/Permutations/Represent.hs
@@ -1,26 +0,0 @@--- |--- Module      :  Phonetic.Languages.Permutations.Represent--- Copyright   :  (c) OleksandrZhabenko 2022--- License     :  MIT--- Stability   :  Experimental--- Maintainer  :  olexandr543@yahoo.com------ Permutations data type to mark the needed permutations type from the other modules.--module Phonetic.Languages.Permutations.Represent (-  PermutationsType(..)-  , bTransform2Perms-) where--import Data.Monoid--data PermutationsType = P Int deriving (Eq, Ord)--instance Show PermutationsType where-  show (P x) = "+p " `mappend` show x--bTransform2Perms :: [String] -> PermutationsType-bTransform2Perms ys- | ys == ["1"] = P 1- | ys == ["2"] = P 2- | otherwise = P 0
phonetic-languages-permutations-array.cabal view
@@ -2,14 +2,14 @@ -- For further documentation, see http://haskell.org/cabal/users-guide/  name:                phonetic-languages-permutations-array-version:             0.3.4.0+version:             0.4.0.0 synopsis:            Permutations and universal set related functions for the phonetic-languages series description:         Permutations-related to produce universal set of the task. Uses arrays instead of vectors. homepage:            https://hackage.haskell.org/package/phonetic-languages-permutations-array license:             MIT license-file:        LICENSE author:              OleksandrZhabenko-maintainer:          olexandr543@yahoo.com+maintainer:          oleksandr.zhabenko@yahoo.com copyright:           Oleksandr Zhabenko category:            Language,Math,Game build-type:          Simple@@ -17,9 +17,9 @@ cabal-version:       >=1.10  library-  exposed-modules:     Phonetic.Languages.Permutations.Arr, Phonetic.Languages.Permutations.ArrMini, Phonetic.Languages.Permutations.ArrMini1, Phonetic.Languages.Permutations.Represent+  exposed-modules:     Phladiprelio.PermutationsArr, Phladiprelio.PermutationsArrMini, Phladiprelio.PermutationsArrMini1, Phladiprelio.PermutationsRepresent   -- other-modules:-  other-extensions:    MultiWayIf-  build-depends:       base >=4.8 && <5, subG ==0.5.3.0+  other-extensions:    MultiWayIf, NoImplicitPrelude+  build-depends:       base >=4.13 && <5, subG ==0.6.1.0   -- hs-source-dirs:   default-language:    Haskell2010