On Sun, 02 Apr 2006, "Jared Updike" <[EMAIL PROTECTED]> wrote:

> Something like "distribute fst (==)" where
>
>> distribute f op x y = f x `op` f y

A function like this has been suggested for the standard libraries a
couple of times before. Someone suggested the name "on", which I quite
like:

  (*) `on` f = \x y -> f x * f y

>> unionBy (distribute fst (==)) listOfPairs1 listOfPairs2

unionBy ((==) `on` fst) xs ys

I think on makes the code rather readable: union by equality on first.

-- 
/NAD

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to