From e266ae1564cb39083a6778f6fdeda06973e1bc86 Mon Sep 17 00:00:00 2001 From: Matthias Braendli Date: Mon, 9 Feb 2015 14:48:19 +0100 Subject: Some maybe things --- foo.hs | 9 +++++++++ 1 file changed, 9 insertions(+) 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 -- cgit v1.2.3