
8 Dec
2004
8 Dec
'04
4:13 a.m.
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