Steven Huwig wrote:


On Dec 6, 2004, at 11:05 PM, Tom Pledger wrote:

   import Data.Char(isSpace)
   import Data.List(groupBy)

   (op `on` f) x y = f x `op` f y
   wordsAndSpaces  = groupBy ((==) `on` isSpace)


`on` is a handy little function in this instance.

Does it have a technical name?


Perhaps, but I don't know it, and wanted to make the code sound OK when read aloud. :-)

Have you used it elsewhere?


Yes, a few times, mainly as (compare `on` fst), as in:

   -- Apply to xs the permutation that would stably sort ks
   unpermute ks xs
       = map snd (sortBy (compare `on` fst) (zip ks xs))

Regards,
Tom


_______________________________________________ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to