[Pkg-haskell-commits] [SCM] haskell-testpack branch, master, updated. debian/1.0.2-1-4-gb0d6b36

John Goerzen jgoerzen at complete.org
Fri Apr 23 14:42:26 UTC 2010


The following commit has been merged in the master branch:
commit c21dbc0acc763b4a6fda735d55322bbc700a6e29
Author: John Goerzen <jgoerzen at complete.org>
Date:   Tue Oct 5 20:25:17 2004 +0100

    Have working split
    
    Keywords:
    
    
    (jgoerzen at complete.org--projects/missingh--head--1.0--patch-10)

diff --git a/MissingH/Strutil.hs b/MissingH/Strutil.hs
index b0f1230..90847c6 100644
--- a/MissingH/Strutil.hs
+++ b/MissingH/Strutil.hs
@@ -69,7 +69,9 @@ rstrip = reverse . lstrip . reverse
 
 Example:
 
-> split "," "foo,bar,,baz" -> ["foo", "bar", "", "baz"]
+> split "," "foo,bar,,baz," -> ["foo", "bar", "", "baz", ""]
+
+> split "ba" ",foo,bar,,baz," -> [",foo,","r,,","z,"]
 -}
 split :: String -> String -> [String]
 split delim str =
@@ -77,7 +79,9 @@ split delim str =
         splitworker delim [] [] = []
         splitworker delim [] accum = [accum]
         splitworker delim str accum =
-            if startswith delim str then
+            if delim == str then 
+               accum : [] : []
+            else if startswith delim str then
                accum : splitworker delim (drop (length delim) str) []
             else splitworker delim (tail str) (accum ++ [head str])
         in

-- 
haskell-testpack



More information about the Pkg-haskell-commits mailing list