[Haskell-cafe] Re: ANNOUNCE: The Monad.Reader - Issue 6

Arie Peterson ariep at xs4all.nl
Wed Jan 31 18:22:01 EST 2007


Pixel wrote:

> i ended up with this one:
>
> dwBool predicate l = (foldr combine (\_ -> []) l) True
>     where
>       combine e fl beg = if beg && predicate e
>                          then fl True
>                          else e : fl False
>
> higher-order, like solutions 3 & 4, but simpler IMO :p

This looks more like solution 1 to me. The only real difference is that
you use 'Bool -> a' to keep track of the two intermediate results, where
solution 1 uses the isomorphic '(a,a)'.

Nice exercise!


Kind regards,

Arie



More information about the Haskell-Cafe mailing list