Haskell 98 Report

Zhanyong Wan zhanyong.wan@yale.edu
Wed, 30 May 2001 17:15:48 -0400


Tom Pledger wrote:
> 
> Zhanyong Wan writes:
>  :
>  | I can't help wondering why it isn't
>  |
>  |   deleteBy'          :: (a -> Bool) -> [a] -> [a]
>  |   deleteBy' f []     = []
>  |   deleteBy' f (y:ys) = if f y then ys else
>  |                          y : deleteBy' f ys
> 
>      deleteBy'' f = filter (not . f)

No.  deleteBy' f only deletes the *first* element that satisfies the
predicate f, while filter (not . f) deletes *all* such elements.

-- Zhanyong