
28 Feb
2012
28 Feb
'12
6:25 p.m.
On Tue, Feb 28, 2012 at 06:06:25PM +0100, Johan Holmquist wrote:
inter :: (a -> a -> b) -> [a] -> [b] inter f [] = [] inter f l = map (uncurry f) $ zip l (tail l)
I've never seen this function defined anywhere, but it looks nice.
withPair :: (a' -> b' -> c) -> (a -> a') -> (b -> b') -> (a,b) -> c withPair f fa fb (a,b) = fa a `f` fb b
Note that withPair f g h === uncurry f . (g *** h) although using withPair is probably nicer (it certainly involves fewer parentheses). -Brent