diff options
author | Matthias Braendli <matthias.braendli@u-blox.com> | 2015-02-09 14:48:19 +0100 |
---|---|---|
committer | Matthias Braendli <matthias.braendli@u-blox.com> | 2015-02-09 14:48:19 +0100 |
commit | e266ae1564cb39083a6778f6fdeda06973e1bc86 (patch) | |
tree | 910b243de57feed995946d2256bc4ee55e98a0ed /foo.hs | |
parent | f16f1a981db23a76ff2d68f76f5ef960427e00cc (diff) | |
download | haskell-e266ae1564cb39083a6778f6fdeda06973e1bc86.tar.gz haskell-e266ae1564cb39083a6778f6fdeda06973e1bc86.tar.bz2 haskell-e266ae1564cb39083a6778f6fdeda06973e1bc86.zip |
Some maybe things
Diffstat (limited to 'foo.hs')
-rw-r--r-- | foo.hs | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -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 |