phonetic-languages-permutations-array (empty) → 0.1.0.0
raw patch · 5 files changed
+107/−0 lines, 5 filesdep +basedep +subGsetup-changed
Dependencies added: base, subG
Files
- CHANGELOG.md +5/−0
- LICENSE +20/−0
- Phonetic/Languages/Permutations/Arr.hs +55/−0
- Setup.hs +2/−0
- phonetic-languages-permutations-array.cabal +25/−0
+ CHANGELOG.md view
@@ -0,0 +1,5 @@+# Revision history for phonetic-languages-permutations-array++## 0.1.0.0 -- 2020-12-31++* First version. Released on an unsuspecting world.
+ LICENSE view
@@ -0,0 +1,20 @@+Copyright (c) 2020 OleksandrZhabenko++Permission is hereby granted, free of charge, to any person obtaining+a copy of this software and associated documentation files (the+"Software"), to deal in the Software without restriction, including+without limitation the rights to use, copy, modify, merge, publish,+distribute, sublicense, and/or sell copies of the Software, and to+permit persons to whom the Software is furnished to do so, subject to+the following conditions:++The above copyright notice and this permission notice shall be included+in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ Phonetic/Languages/Permutations/Arr.hs view
@@ -0,0 +1,55 @@+-- |+-- Module : Phonetic.Languages.Permutations.Arr+-- Copyright : (c) OleksandrZhabenko 2020+-- License : MIT+-- Stability : Experimental+-- Maintainer : olexandr543@yahoo.com+--+-- Permutation 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 '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+ -> [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 #-}
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ phonetic-languages-permutations-array.cabal view
@@ -0,0 +1,25 @@+-- Initial phonetic-languages-permutations.cabal generated by cabal init.+-- For further documentation, see http://haskell.org/cabal/users-guide/++name: phonetic-languages-permutations-array+version: 0.1.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+copyright: Oleksandr Zhabenko+category: Language,Math,Game+build-type: Simple+extra-source-files: CHANGELOG.md+cabal-version: >=1.10++library+ exposed-modules: Phonetic.Languages.Permutations.Arr+ -- other-modules:+ -- other-extensions:+ build-depends: base >=4.8 && <4.15, subG >=0.4.2 && <1+ -- hs-source-dirs:+ default-language: Haskell2010