You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

14 lines
388 B

  1. Let's abstract out the common pieces! This will be our type signature:
  2. \begin{haskellcode}
  3. filter :: (a -> Bool) -> [a] -> [a]
  4. \end{haskellcode}
  5. Solution?
  6. \pause
  7. \begin{haskellcode}
  8. filter :: (a -> Bool) -> [a] -> [a]
  9. filter f [] = []
  10. filter f (x:xs)
  11. | f x = x : filter f xs
  12. | otherwise = filter f xs
  13. \end{haskellcode}
  14. Again: this function is part of the \emph{Prelude} as well.