Scrapbook-0.4.0: code examples
Copyright© Frank Jung 2020
LicenseGPL-3
Safe HaskellSafe-Inferred
LanguageHaskell2010

MyFilter

Description

Filter a list using fold. In the Prelude, filter is defined as a recursive function:

  filter :: (a -> Bool) -> [a] -> [a]
  filter _pred []    = []
  filter pred (x:xs)
    | pred x         = x : filter pred xs
    | otherwise      = filter pred xs
Synopsis

Documentation

myFilter :: (Foldable t, Ord a) => (a -> Bool) -> t a -> [a] Source #

Filter a list using foldr.