packages feed

palindromes 0.2 → 0.2.1

raw patch · 4 files changed

+27/−17 lines, 4 filesdep ~base

Dependency ranges changed: base

Files

RELEASE_HISTORY view
@@ -1,6 +1,6 @@ Release history: -Version 2+100110 Version 2 Read from standard input, via the flag -i More flexible flag handling Read multiple files
palindromes.cabal view
@@ -1,5 +1,5 @@ name:                   palindromes-version:                0.2+version:                0.2.1 synopsis:               Finding palindromes in strings homepage:               http://www.jeuring.net/Palindromes description:@@ -8,7 +8,7 @@   returns information about palindromes in the file.  category:               Algorithms-copyright:              (c) 2007 - 2010 Johan Jeuring+copyright:              (c) 2007 - 2011 Johan Jeuring license:                BSD3 license-file:           LICENSE author:                 Johan Jeuring@@ -28,13 +28,13 @@   hs-source-dirs:       src   exposed-modules:      Data.Algorithms.Palindromes.Palindromes -Executable	            palindromes-  Main-is:				Data/Algorithms/Palindromes/Main.hs+Executable              palindromes+  Main-is:              Data/Algorithms/Palindromes/Main.hs   ghc-options:          -Wall   hs-source-dirs:       src   other-modules:        Data.Algorithms.Palindromes.Palindromes,                         Data.Algorithms.Palindromes.Options-  build-depends:        base >= 3.0 && < 4.0,+  build-depends:        base >= 3.0 && < 5,                         array  --------------------------------------------------------------------------------
src/Data/Algorithms/Palindromes/Main.hs view
@@ -26,9 +26,12 @@   let hFW filenames =          case filenames of           []        ->  putStr (f "")-          (fn:fns)  ->  do input <- readFile fn-                           putStrLn (f input)-                           hFW fns+          (fn:fns)  ->  do -- input <- readFile fn+                         fn' <- openFile fn ReadMode+                         hSetEncoding fn' latin1 +                         input <- hGetContents fn' +                         putStrLn (f input)+                         hFW fns   in hFW                                   handleStandardInputWith :: (String -> String) -> IO ()
src/Data/Algorithms/Palindromes/Palindromes.hs view
@@ -91,7 +91,7 @@   let inputArray              =  listArrayl0 input       ips                     =  zip input [0..]       textinput               =  map (first toLower) -                                     (filter (isLetter.fst) ips)+                                     (filter (myIsLetter.fst) ips)       textInputArray          =  listArrayl0 (map fst textinput)       positionTextInputArray  =  listArrayl0 (map snd textinput)   in  longestTextPalindromeArray @@ -119,7 +119,7 @@   let inputArray              =  listArrayl0 input       ips                     =  zip input [0..]       textinput               =  map (first toLower) -                                     (filter (isLetter.fst) ips)+                                     (filter (myIsLetter.fst) ips)       textInputArray          =  listArrayl0 (map fst textinput)       positionTextInputArray  =  listArrayl0 (map snd textinput)   in  concat @@ -153,7 +153,7 @@   let inputArray              =  listArrayl0 input       ips                     =  zip input [0..]       textinput               =  map (first toLower) -                                     (filter (isLetter.fst) ips)+                                     (filter (myIsLetter.fst) ips)       textInputArray          =  listArrayl0 (map fst textinput)       positionTextInputArray  =  listArrayl0 (map snd textinput)   in  longestWordPalindromeArray @@ -183,7 +183,7 @@   let inputArray              =  listArrayl0 input       ips                     =  zip input [0..]       textinput               =  map (first toLower) -                                     (filter (isLetter.fst) ips)+                                     (filter (myIsLetter.fst) ips)       textInputArray          =  listArrayl0 (map fst textinput)       positionTextInputArray  =  listArrayl0 (map snd textinput)   in  concat @@ -214,11 +214,11 @@       then False       else if startpos' <= fst (bounds inputArray)            then endpos' >= snd (bounds inputArray) ||-                not (isLetter (inputArray!!!(endpos'+1)))+                not (myIsLetter (inputArray!!!(endpos'+1)))            else if endpos' >= snd (bounds inputArray) -                then not (isLetter (inputArray!!!(startpos'-1)))-                else not (isLetter (inputArray!!!(startpos'-1)))-                  && not (isLetter (inputArray!!!(endpos'+1)))+                then not (myIsLetter (inputArray!!!(startpos'-1)))+                else not (myIsLetter (inputArray!!!(startpos'-1)))+                  && not (myIsLetter (inputArray!!!(endpos'+1)))  ----------------------------------------------------------------------------- -- palindromesAroundCentres @@ -317,6 +317,13 @@                              then positionArray!!!(endpos+1)-1                              else snd (bounds inputArray)             in  show [inputArray!n | n<- [start..end]]++-----------------------------------------------------------------------------+-- Character utils+-----------------------------------------------------------------------------++myIsLetter :: Char -> Bool+myIsLetter = not . flip elem ",.;:!?`~/<> \a\b\f\n\r\t\v\\\"\'\&"  ----------------------------------------------------------------------------- -- Array utils