catMaybes (x:xs) = 
  case x of
    (Just n) -> n : catMaybes xs
    _        -> catMaybes xs

-- 6. You'll see this called "sequence" later. 

-- flipMaybe [Just 1, Just 2, Just 3]
-- Just [1, 2, 3]

-- flipMaybe [Just 1, Nothing, Just 3]
-- Nothing
catMaybes (x:xs) = 
  case x of
    (Just n) -> n : catMaybes xs
    _        -> catMaybes xs

-- 6. You'll see this called "sequence" later. 

-- flipMaybe [Just 1, Just 2, Just 3]
-- Just [1, 2, 3]

-- flipMaybe [Just 1, Nothing, Just 3]
-- Nothing
catMaybes (x:xs) = 
  case x of
    (Just n) -> n : catMaybes xs
    _        -> catMaybes xs

-- 6. You'll see this called "sequence" later. 

-- flipMaybe [Just 1, Just 2, Just 3]
-- Just [1, 2, 3]

-- flipMaybe [Just 1, Nothing, Just 3]
-- Nothing