packages feed

string-interpreter 0.2.0.0 → 0.3.0.0

raw patch · 3 files changed

+13/−6 lines, 3 files

Files

ChangeLog.md view
@@ -7,3 +7,8 @@ ## 0.2.0.0 -- 2021-08-16  * Second version. Added a possibility to specify also splitting of the word.++## 0.3.0.0 -- 2021-08-31++* Third version. Added the possibility to specify dividing using negative second +part that is counting from the end of the word in the opposite direction.
Interpreter/StringConversion.hs view
@@ -12,22 +12,24 @@ module Interpreter.StringConversion where  import Text.Read (readMaybe)-import Data.Maybe+import Data.Maybe (fromJust,fromMaybe) import Data.Char (isDigit)-import Data.List (sort,nub,intercalate,(\\))+import Data.List (sort,nub,(\\)) import Data.Monoid (mappend)  convStringInterpreter :: String -> String -> String convStringInterpreter contrs xs  | null contrs = xs  | null . words $ xs = xs- | case filter (\y -> isDigit y || y == '/') contrs of { a:'/':bs -> a /= '/' && a /= '0' ; ~rrr -> False } =+ | case filter (\y -> isDigit y || y == '/' || y == '-') contrs of { a:'/':bs -> a /= '/' && a /= '0' ; ~rrr -> False } =      let ys = filter (\y -> isDigit y || y == '/') contrs in        case ys of          ~a:'/':bs -> let wordsN = words xs                           wordN = min (fromMaybe 1 (readMaybe [a]::Maybe Int)) (length wordsN)                           pos = fromMaybe 0 (readMaybe bs::Maybe Int)-                          (ts,us) = splitAt pos (wordsN !! (wordN - 1))+                          wrdP = wordsN !! (wordN - 1)+                          (ts,us) | pos >= 0 = splitAt pos wrdP+                                  | otherwise = splitAt (length wrdP + pos) wrdP                           twoWords = ts `mappend` (' ':us)                           (wss,tss) = splitAt (wordN - 1) wordsN                           kss = drop 1 tss in@@ -42,7 +44,7 @@                                (zss,yss) = splitAt (pos - 1) tss                                (kss,lss) = splitAt number yss in                                  if length tss < pos + number - 1 then xs-                                 else if null zss then concat kss `mappend` " " `mappend` intercalate " " lss+                                 else if null zss then concat kss `mappend` " " `mappend` unwords lss                                       else unwords zss `mappend` " " `mappend` concat kss `mappend` " " `mappend` unwords lss                       _ -> let idxs = map (\x -> fromJust (readMaybe [x]::Maybe Int)) $ cntrs                                wordsN = map (\i -> tss !! (i - 1)) idxs
string-interpreter.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                string-interpreter-version:             0.2.0.0+version:             0.3.0.0 synopsis:            Is used in the recursive mode for phonetic languages approach. description:         A library that has commonly used function for the phonetic-languages implementations. homepage:            https://hackage.haskell.org/package/string-interpreter