[Haskell-cafe] Knowledge

Neil Mitchell ndmitchell at gmail.com
Wed Dec 19 16:41:56 EST 2007


Hi

> > contains :: Eq a => [a]->a->Bool
> > contains [] e = False
> > contains (x:xs) e = if x==e then True else contains xs e
>
> contains = flip elem

And even if not using the elem function, the expression:

if x==e then True else contains xs e

can be written as:

x==e || contains xs e

Thanks

Neil


More information about the Haskell-Cafe mailing list