[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 15:09:21 UTC 2010
The following commit has been merged in the master branch:
commit 7b94dec6d64173a7be45c533a018180f0ebe6332
Author: John Goerzen <jgoerzen at complete.org>
Date: Sat Apr 8 02:31:47 2006 +0100
New function: MissingH.List.hasAny
diff --git a/MissingH/List.hs b/MissingH/List.hs
index a539487..d741948 100644
--- a/MissingH/List.hs
+++ b/MissingH/List.hs
@@ -1,5 +1,5 @@
{- arch-tag: List utilities main file
-Copyright (C) 2004-2005 John Goerzen <jgoerzen at complete.org>
+Copyright (C) 2004-2006 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
@@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
{- |
Module : MissingH.List
- Copyright : Copyright (C) 2004-2005 John Goerzen
+ Copyright : Copyright (C) 2004-2006 John Goerzen
License : GNU GPL, version 2 or above
Maintainer : John Goerzen <jgoerzen at complete.org>
@@ -31,7 +31,7 @@ Written by John Goerzen, jgoerzen\@complete.org
-}
module MissingH.List(-- * Tests
- startswith, endswith, contains,
+ startswith, endswith, contains, hasAny,
-- * Association List Utilities
{- | These functions are designed to augment the
association list functions in "Data.List" and
@@ -86,6 +86,15 @@ Example:
endswith :: Eq a => [a] -> [a] -> Bool
endswith = isSuffixOf
+{- | Returns true if the given list contains any of the elements in the search
+list. -}
+hasAny :: Eq a => [a] -- ^ List of elements to look for
+ -> a -- ^ List to search
+ -> Bool -- ^ Result
+hasAny [] _ = False -- An empty search list: always false
+hasAny _ [] = False -- An empty list to scan: always false
+hasAny search (x:xs) = if x `elem` search then True else hasAny search xs
+
{- | Similar to Data.List.takeWhile, takes elements while the func is true.
The function is given the remainder of the list to examine. -}
takeWhileList :: ([a] -> Bool) -> [a] -> [a]
--
haskell-testpack
More information about the Pkg-haskell-commits
mailing list