« Return to Thread: Knowledge

Re: Knowledge

by Neil Mitchell :: Rate this Message:

Reply to Author | View in Thread

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
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@...
http://www.haskell.org/mailman/listinfo/haskell-cafe

 « Return to Thread: Knowledge