packages feed

uniqueness-periods-vector-general (empty) → 0.1.0.0

raw patch · 5 files changed

+254/−0 lines, 5 filesdep +basedep +uniqueness-periods-vectordep +uniqueness-periods-vector-commonsetup-changed

Dependencies added: base, uniqueness-periods-vector, uniqueness-periods-vector-common, vector

Files

+ ChangeLog.md view
@@ -0,0 +1,5 @@+# Revision history for uniqueness-periods-vector-general++## 0.1.0.0 -- YYYY-mm-dd++* 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.
+ Languages/UniquenessPeriods/Vector/General/Debug.hs view
@@ -0,0 +1,202 @@+-- |+-- Module      :  Languages.UniquenessPeriods.Vector.General.Debug+-- Copyright   :  (c) OleksandrZhabenko 2020+-- License     :  MIT+-- Stability   :  Experimental+-- Maintainer  :  olexandr543@yahoo.com+--+-- Generalization of the functionality of the DobutokO.Poetry.General.Debug +-- module from the @dobutokO-poetry-general-languages@ package. ++module Languages.UniquenessPeriods.Vector.General.Debug where++import Data.Maybe (fromJust)+import Data.Char (isPunctuation)+import qualified Data.Vector as V+import Languages.UniquenessPeriods.Vector.Auxiliary+import String.Languages.UniquenessPeriods.Vector+import Languages.UniquenessPeriods.Vector.StrictV+import Languages.UniquenessPeriods.Vector.Data++++-- | +uniqMaxPoeticalGNV :: +  (Eq a, Ord b) => Int +  -> V.Vector ([b] -> b) +  ->  UniqG a b +  -> UniquenessG1 a b+uniqMaxPoeticalGNV k vN y+ | compare k (V.length vN) == GT = error "Languages.UniquenessPeriods.Vector.General.Debug.uniqMaxPoeticalGNV: undefined for that amount of norms. "+ | compare k 0 == GT =+   let maxK = V.maximumBy (\(_,vN0,_) (_,vN1,_) -> compare (V.unsafeIndex vN0 (k - 1)) (V.unsafeIndex vN1 (k - 1))) . snd . get2 $ y+       vK = V.filter (\(_,vN2,_) -> V.unsafeIndex vN2 (k - 1) == ((\(_,vNk,_) -> V.unsafeIndex vNk (k - 1)) maxK)) . snd . get2 $ y in+         if isU y then uniqMaxPoeticalGNV (k - 1) (V.unsafeSlice 0 (V.length vN - 1) vN) (U vK)+         else uniqMaxPoeticalGNV (k - 1) (V.unsafeSlice 0 (V.length vN - 1) vN) (UL (fromJust . fst . get2 $ y,vK))+ | otherwise = V.maximumBy (\(_,vN0,_) (_,vN1,_) -> compare (V.unsafeIndex vN0 0) (V.unsafeIndex vN1 0)) . snd . get2 $ y+{-# INLINE uniqMaxPoeticalGNV #-}++-- | +inner1 :: +  (Eq a, Ord b, Show a, Show b) => Int +  -> V.Vector ([b] -> b) +  -> UniqG a b +  -> IO ([b],UniqG a b)+inner1 k vN x = do +  let uniq = uniqMaxPoeticalGNV k vN x+  let fsT = (\(ys,_,_) -> ys) uniq+  putStrLn . show . lastFrom3 $ uniq+  putStrLn . show . firstFrom3 $ uniq+  putStrLn . show . secondFrom3 $ uniq+  return (fsT,x)+{-# INLINE inner1 #-}++-- | +uniqMaxPoeticalGNVL :: +  (Eq a, Ord b, Show a, Show b) => V.Vector ([b] -> b) +  ->  UniqG a b +  -> UniquenessG1 a b+uniqMaxPoeticalGNVL vN = uniqMaxPoeticalGNV (V.length vN) vN+{-# INLINE uniqMaxPoeticalGNVL #-}++-- | +uniqMaxPoetical2GN :: +  (Eq a, Ord b, Show a, Show b) => [a] +  -> Preapp a+  -> Int +  -> V.Vector ([b] -> b) +  ->  ([a] -> V.Vector c)+  -> (V.Vector c -> [b]) +  -> [a] +  -> UniquenessG1 a b+uniqMaxPoetical2GN whspss rr k vN g1 g2 xs+ | compare k (V.length vN) == GT = error "Languages.UniquenessPeriods.Vector.General.Debug.uniqMaxPoetical2GN: undefined for that amount of norms. "+ | compare k 0 == GT =+   let vM = uniquenessVariants2GNP (get1m rr) (get2m rr) whspss vN g1 g2 xs+       maxK = V.maximumBy (\(_,vN0,_) (_,vN1,_) -> compare (V.unsafeIndex vN0 (k - 1)) (V.unsafeIndex vN1 (k - 1))) vM+       vK = V.filter (\(_,vN2,_) -> V.unsafeIndex vN2 (k - 1) == ((\(_,vNk,_) -> V.unsafeIndex vNk (k - 1)) maxK)) vM in+         uniqMaxPoeticalGNV (k - 1) (V.unsafeSlice 0 (V.length vN - 1) vN) (U vK)+ | otherwise = V.maximumBy (\(_,vN0,_) (_,vN1,_) -> compare (V.unsafeIndex vN0 0) (V.unsafeIndex vN1 0)) . uniquenessVariantsGN whspss rr vN g1 g2 $ xs++-- | +uniquenessVariantsGN :: +  (Eq a, Ord b, Show a, Show b) => [a] +  -> Preapp a +  -> V.Vector ([b] -> b) +  ->  ([a] -> V.Vector c)+  -> (V.Vector c -> [b]) +  -> [a] +  -> V.Vector (UniquenessG1 a b)+uniquenessVariantsGN whspss (PA ts us) vN g1 g2 = uniquenessVariants2GNP ts us whspss vN g1 g2+uniquenessVariantsGN whspss K vN g1 g2 = uniquenessVariants2GN whspss vN g1 g2+{-# INLINE uniquenessVariantsGN #-}++-- | +uniqInMaxPoeticalN :: +  (Eq a, Ord b, Show a, Show b) => Int +  -> V.Vector ([b] -> b) +  -> UniqG a b +  -> IO (UniqG a b)+uniqInMaxPoeticalN k vN x = do+  inner1 k vN x >>= \(fsT,x) -> +    if isU x then return (U (V.filter (\(xs,_,_) -> xs /= fsT) . snd . get2 $ x))+    else return (UL ((\(v1,v2) -> ((V.toList . V.map lastFrom3 $ v1) ++ (fromJust . fst . get2 $ x),v2)) . +      V.unstablePartition (\(xs,_,_) -> xs == fsT) . snd . get2 $ x))+{-# INLINE uniqInMaxPoeticalN #-}+  +-- | +uniqInMaxPoeticalNL :: +  (Eq a, Ord b, Show a, Show b) => V.Vector ([b] -> b) +  -> UniqG a b +  -> IO (UniqG a b)+uniqInMaxPoeticalNL vN = uniqInMaxPoeticalN (V.length vN) vN+{-# INLINE uniqInMaxPoeticalNL #-}++-- | +uniqNPoeticalN :: +  (Eq a, Ord b, Show a, Show b) => Int +  -> Int +  -> V.Vector ([b] -> b) +  -> UniqG a b -> IO ()+uniqNPoeticalN n k vN y  + | n <= 0 = return ()+ | compare (V.length . snd . get2 $ y) n == LT = V.mapM_ (\x -> do +   { putStrLn . show . lastFrom3 $ x+   ; putStrLn . show . firstFrom3 $ x+   ; putStrLn . show . secondFrom3 $ x}) . snd . get2 $ y+ | otherwise = (uniqInMaxPoeticalN k vN y >>= uniqNPoeticalN (n - 1) k vN)+{-# INLINE uniqNPoeticalN #-}++-- | +uniqNPoeticalNL :: +  (Eq a, Ord b, Show a, Show b) => Int +  -> V.Vector ([b] -> b) +  -> UniqG a b +  -> IO ()+uniqNPoeticalNL n vN = uniqNPoeticalN n (V.length vN) vN+{-# INLINE uniqNPoeticalNL #-}++-- | +uniqNPoeticalVN :: +  (Eq a, Ord b, Show a, Show b) => Int +  -> Int +  -> V.Vector ([b] -> b) +  -> UniqG a b +  -> IO (UniqG a b)+uniqNPoeticalVN n k vN y+ | n <= 0 || compare (V.length . snd . get2 $ y) n == LT = return y+ | otherwise = (uniqInMaxPoeticalN k vN y >>= uniqNPoeticalVN (n - 1) k vN)+{-# INLINE uniqNPoeticalVN #-}++-- | +uniqNPoeticalVNL :: +  (Eq a, Ord b, Show a, Show b) => Int +  -> V.Vector ([b] -> b) +  -> UniqG a b +  -> IO (UniqG a b)+uniqNPoeticalVNL n vN = uniqNPoeticalVN n (V.length vN) vN+{-# INLINE uniqNPoeticalVNL #-}++--------------------------------------------------------------------------------------------++-- | +uniqNPoetical2GN :: +  (Eq a, Ord b, Show a, Show b) => [a]+  -> Preapp a +  -> Int +  -> Int +  -> V.Vector ([b] -> b) +  -> ([a] -> V.Vector c)+  -> (V.Vector c -> [b]) +  -> [a] +  -> IO ()+uniqNPoetical2GN whspss rr n k vN g1 g2 xs+ | n <= 0 = return ()+ | otherwise = do+   let v = uniquenessVariants2GNP whspss (get1m rr) (get2m rr) vN g1 g2 xs+   if compare (V.length v) n == LT+     then V.mapM_ (\x -> do +       { putStrLn . show . lastFrom3 $ x+       ; putStrLn . show . firstFrom3 $ x+       ; putStrLn . show . secondFrom3 $ x}) v+     else (uniqInMaxPoeticalN k vN (U v) >>= uniqNPoeticalN (n - 1) k vN)++-- | +uniqNPoetical2VGN :: +  (Eq a, Ord b, Show a, Show b) => [a]+  -> Preapp a +  -> Int +  -> Int +  -> V.Vector ([b] -> b) +  -> ([a] -> V.Vector c)+  -> (V.Vector c -> [b]) +  -> UniqG a b +  -> [a] +  -> IO (UniqG a b)+uniqNPoetical2VGN whspss rr n k vN g1 g2 y xs+ | n <= 0 = if isU y then return (U V.empty) else return (UL ([],V.empty))+ | otherwise = do+   let v = uniquenessVariants2GNP whspss (get1m rr) (get2m rr) vN g1 g2 xs+   if compare (V.length v) n == LT +     then if isU y then return (U v) else return (UL ([],v)) +     else if isU y then uniqNPoeticalVN n k vN (U v) else uniqNPoeticalVN n k vN (UL ([],v))
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ uniqueness-periods-vector-general.cabal view
@@ -0,0 +1,25 @@+-- Initial uniqueness-periods-vector-general.cabal generated by cabal init.+--   For further documentation, see http://haskell.org/cabal/users-guide/++name:                uniqueness-periods-vector-general+version:             0.1.0.0+synopsis:            Generalization of the functionality of the dobutokO-poetry-general-languages package+description:         Generalization of the functionality of the dobutokO-poetry-general-languages package+homepage:            https://hackage.haskell.org/package/uniqueness-periods-vector-general+license:             MIT+license-file:        LICENSE+author:              OleksandrZhabenko+maintainer:          olexandr543@yahoo.com+copyright:           Oleksandr Zhabenko+category:            Language, Game, Math+build-type:          Simple+extra-source-files:  ChangeLog.md+cabal-version:       >=1.10++library+  exposed-modules:     Languages.UniquenessPeriods.Vector.General.Debug+  -- other-modules:+  -- other-extensions:+  build-depends:       base >=4.7 && <4.15, vector >=0.11 && <0.14, uniqueness-periods-vector-common >=0.1 && <1, uniqueness-periods-vector >=0.1 && <1+  -- hs-source-dirs:+  default-language:    Haskell2010