[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:24 UTC 2010


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

    Fixed docs, started listutil
    
    Keywords:
    
    
    (jgoerzen at complete.org--projects/missingh--head--1.0--patch-7)

diff --git a/MissingH/Listutil.hs b/MissingH/Listutil.hs
new file mode 100644
index 0000000..250c8b5
--- /dev/null
+++ b/MissingH/Listutil.hs
@@ -0,0 +1,53 @@
+{- arch-tag: List utilities main file
+Copyright (C) 2004 John Goerzen <jgoerzen at complete.org>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+-}
+
+{- | This module provides various helpful utilities for dealing with lists.
+
+Written by John Goerzen, jgoerzen\@complete.org
+-}
+
+module MissingH.Listutil(-- * Tests
+                         startswith, endswith
+                        ) where
+
+{- | Returns true if the given list starts with the specified elements;
+false otherwise.
+
+Example:
+@
+startswith He Hello -> True
+@
+-}
+
+startswith :: Eq a => [a] -> [a] -> Bool
+startswith [] _ = True
+startswith _ [] = False
+startswith (x:xs) (l:ls) =
+    if (x == l) then startswith xs ls
+    else False
+
+{- | Returns true if the given list ends with the specified elements;
+false otherwise.
+
+Example:
+@
+endswith lo Hello True
+@
+-}
+endswith :: Eq a => [a] -> [a] -> Bool
+endswith x l = startswith (reverse x) (reverse l)
diff --git a/MissingH/Strutil.hs b/MissingH/Strutil.hs
index 352a02c..e680e7c 100644
--- a/MissingH/Strutil.hs
+++ b/MissingH/Strutil.hs
@@ -18,12 +18,15 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 {- | This module provides various helpful utilities for dealing with strings.
 
-Written by John Goerzen, jgoerzen at complete.org
+Written by John Goerzen, jgoerzen\@complete.org
 -}
 
-module MissingH.Strutil(
-                        -- * Whitespace Removal
-                        strip, lstrip, rstrip) where
+module MissingH.Strutil(-- * Whitespace Removal
+                        strip, lstrip, rstrip,
+                        -- * Tests
+                        startswith, endswith
+                       ) where
+import MissingH.Listutil(startswith, endswith)
 
 wschars = " \t\r\n"
 
@@ -58,21 +61,3 @@ lstrip s = case s of
 rstrip :: String -> String
 rstrip = reverse . lstrip . reverse
 
--- | Returns true if the given list starts with the specified elements;
--- false otherwise.
---
--- Example: startswith "He" "Hello" -> True
-
-startswith :: Eq a => [a] -> [a] -> Bool
-startswith [] _ = True
-startswith _ [] = False
-startswith (x:xs) (l:ls) =
-    if (x == l) then startswith xs ls
-    else False
-
--- | Returns true if the given list ends with the specified elements;
--- false otherwise.
---
--- Example: endswith "lo" "Hello" -> True
-endswith :: Eq a => [a] -> [a] -> Bool
-endswith x l = startswith (reverse x) (reverse l)

-- 
haskell-testpack



More information about the Pkg-haskell-commits mailing list