[Haskell-beginners] Disjunction

Tony Morris tonymorris at gmail.com
Fri Dec 10 02:30:00 CET 2010


On 10/12/10 10:02, Russ Abbott wrote:
> I recently was writing code long these lines.
>
> f x = p1 x || p2 x || ... || pn x
>
> I would have liked to write that in pointfree form but couldn't find a
> library function to do it.
>
> I created this.
>
> disj :: [a -> Bool] -> a -> Bool
> disj ps = (\x -> or $ map ($x) ps)
>
> disj2 p1 p2 = disj [p1, p2]
> disj3 p1 p2 p3 = disj [p1, p2]
> disj4 p1 p2 p3 p4 = disj [p1, p2]
> ...
>
> With that I can write my function as follows.
>
> f = disj pi p2 p3 ... pn
>
> Is there a standard way to do this?
> /
> -- Russ/
>
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>   
disj = fmap or . sequence

-- 
Tony Morris
http://tmorris.net/


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20101210/04c1e95e/attachment-0001.htm>


More information about the Beginners mailing list