summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOleksandrZhabenko <>2020-11-20 15:37:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2020-11-20 15:37:00 (GMT)
commit03e2afbee114a4e5344ac91afa6b22e35880f05e (patch)
treed16660f387cac23d865f8ed33377a113dbe72d8d
parentd19a2ec04e587321249fb5130efb6278ac0fe24b (diff)
version 0.2.0.0HEAD0.2.0.0master
-rw-r--r--CHANGELOG.md5
-rw-r--r--Phonetic/Languages/Permutations.hs25
-rw-r--r--phonetic-languages-permutations.cabal4
3 files changed, 32 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e50bc83..b1e5272 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,3 +7,8 @@
## 0.1.1.0 -- 2020-11-19
* First version revised A. Some code improvements.
+
+## 0.2.0.0 -- 2020-11-20
+
+* Second version. Added three more functions for permutations.
+
diff --git a/Phonetic/Languages/Permutations.hs b/Phonetic/Languages/Permutations.hs
index 70d5a3d..1995fd9 100644
--- a/Phonetic/Languages/Permutations.hs
+++ b/Phonetic/Languages/Permutations.hs
@@ -9,14 +9,19 @@
module Phonetic.Languages.Permutations (
universalSetG
+ , universalSetGL
, genPermutations
, genPermutationsV
+ , genPermutationsL
+ , genPermutationsVL
) where
import qualified Data.Vector as VB
import qualified Data.List as L (permutations)
import Data.SubG
import Data.SubG.InstancesPlus ()
+import qualified Data.Foldable as F (concat,foldr')
+--import Data.List ()
import Data.Monoid
-- | A key point of the evaluation -- the universal set of the task represented as a 'VB.Vector' of 'VB.Vector' of @a@.
@@ -31,6 +36,18 @@ universalSetG ::
universalSetG ts uss f1 f2 perms baseV = VB.map (VB.foldr' mappend mempty . VB.cons (f1 ts) . (`mappend` (f2 uss)) . VB.unsafeBackpermute baseV) perms
{-# INLINE universalSetG #-}
+-- | A key point of the evaluation -- the universal set of the task represented as a 'VB.Vector' of 'VB.Vector' of @a@. Because the order is not
+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
+ -> [VB.Vector Int] -- ^ The list of permutations of 'Int' indices starting from 0 and up to n (n is probably less than 7).
+ -> VB.Vector [a]
+ -> [[a]]
+universalSetGL ts uss f1 f2 permsL baseV = map (F.concat . F.foldr' (:) [] . (f1 ts:) . (`mappend` f2 uss) . VB.toList . VB.unsafeBackpermute baseV) permsL
+{-# INLINE universalSetGL #-}
+
genPermutations :: Int -> VB.Vector (VB.Vector Int)
genPermutations n = VB.map VB.fromList . VB.fromList . L.permutations . take n $ [0..]
{-# INLINE genPermutations #-}
@@ -38,3 +55,11 @@ genPermutations n = VB.map VB.fromList . VB.fromList . L.permutations . take n $
genPermutationsV :: VB.Vector (VB.Vector (VB.Vector Int))
genPermutationsV = VB.map (\n -> VB.map VB.fromList . VB.fromList . L.permutations . take n $ [0..]) . VB.enumFromTo 2 $ 7
{-# INLINE genPermutationsV #-}
+
+genPermutationsL :: Int -> [VB.Vector Int]
+genPermutationsL n = map VB.fromList . L.permutations . take n $ [0..]
+{-# INLINE genPermutationsL #-}
+
+genPermutationsVL :: VB.Vector [VB.Vector Int]
+genPermutationsVL = VB.map (\n -> map VB.fromList . L.permutations . take n $ [0..]) . VB.enumFromTo 2 $ 7
+{-# INLINE genPermutationsVL #-}
diff --git a/phonetic-languages-permutations.cabal b/phonetic-languages-permutations.cabal
index 09c0e63..a765b2c 100644
--- a/phonetic-languages-permutations.cabal
+++ b/phonetic-languages-permutations.cabal
@@ -2,7 +2,7 @@
-- For further documentation, see http://haskell.org/cabal/users-guide/
name: phonetic-languages-permutations
-version: 0.1.1.0
+version: 0.2.0.0
synopsis: Commonly used versions of the phonetic-languages-common package
description: Permutations-related to produce universal set of the task.
homepage: https://hackage.haskell.org/package/phonetic-languages-permutations
@@ -19,7 +19,7 @@ cabal-version: >=1.10
library
exposed-modules: Phonetic.Languages.Permutations
-- other-modules:
- -- other-extensions:
+ -- other-extensions:
build-depends: base >=4.8 && <4.15, vector >=0.11 && <0.14, subG >=0.4.2 && <1, subG-instances >=0.1 && <1
-- hs-source-dirs:
default-language: Haskell2010