summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Braendli <matthias.braendli@u-blox.com>2015-02-09 14:48:19 +0100
committerMatthias Braendli <matthias.braendli@u-blox.com>2015-02-09 14:48:19 +0100
commite266ae1564cb39083a6778f6fdeda06973e1bc86 (patch)
tree910b243de57feed995946d2256bc4ee55e98a0ed
parentf16f1a981db23a76ff2d68f76f5ef960427e00cc (diff)
downloadhaskell-e266ae1564cb39083a6778f6fdeda06973e1bc86.tar.gz
haskell-e266ae1564cb39083a6778f6fdeda06973e1bc86.tar.bz2
haskell-e266ae1564cb39083a6778f6fdeda06973e1bc86.zip
Some maybe things
-rw-r--r--foo.hs9
1 files changed, 9 insertions, 0 deletions
diff --git a/foo.hs b/foo.hs
index 1565904..08b79de 100644
--- a/foo.hs
+++ b/foo.hs
@@ -1,3 +1,5 @@
+import Data.Maybe (catMaybes)
+
foo :: [(Int, Int)]
foo = [(8, 14), (4,2), (3,4)]
@@ -33,4 +35,11 @@ func3 x = x * 5
funcs = [func1, func2, func3]
+maybeints = [ Just 1, Just 2, Nothing, Just 4]
+
+lift_tuple :: (Int, Maybe Int) -> Maybe (Int, Int)
+lift_tuple (a, Just b) = Just (a, b)
+lift_tuple (a, Nothing) = Nothing
+
+pairs = catMaybes $ map lift_tuple $ zip intlist maybeints