[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:57:50 UTC 2010
The following commit has been merged in the master branch:
commit 560abf3d1ec4778ad4227cd86f175bf8a1560118
Author: John Goerzen <jgoerzen at complete.org>
Date: Mon Apr 18 23:35:50 2005 +0100
Added some more association list utilities
diff --git a/MissingH/List.hs b/MissingH/List.hs
index ff6ea8f..4ef6ea5 100644
--- a/MissingH/List.hs
+++ b/MissingH/List.hs
@@ -38,7 +38,8 @@ module MissingH.List(-- * Tests
association list functions in "Data.List" and
provide an interface similar to "Data.FiniteMap"
for association lists. -}
- addToAL, delFromAL, flipAL,
+ addToAL, delFromAL, flipAL, keysAL, valuesAL,
+ hasKeyAL,
-- ** Association List Conversions
strFromAL,
strToAL,
@@ -195,6 +196,30 @@ matches the given one. -}
delFromAL :: Eq key => [(key, a)] -> key -> [(key, a)]
delFromAL l key = filter (\a -> (fst a) /= key) l
+{- | Returns the keys that comprise the (key, value) pairs of the given AL.
+
+Same as:
+
+>map fst
+-}
+keysAL :: [(key, a)] -> [key]
+keysAL = map fst
+
+{- | Returns the values the comprise the (key, value) pairs of the given
+AL.
+
+Same as:
+
+>map snd
+-}
+valuesAL :: [(a, value)] -> [value]
+valuesAL = map snd
+
+{- | Indicates whether or not the given key is in the AL. -}
+hasKeyAL :: Eq a => a -> [(a, b)] -> Bool
+hasKeyAL key list =
+ elem key (keysAL list)
+
{- | Flips an association list. Converts (key1, val), (key2, val) pairs
to (val, [key1, key2]). -}
flipAL :: (Eq key, Eq val) => [(key, val)] -> [(val, [key])]
--
haskell-testpack
More information about the Pkg-haskell-commits
mailing list