
28 Feb
2012
28 Feb
'12
8:08 p.m.
Am 28.02.2012 um 20:21 schrieb Johan Holmquist:
inter :: (a -> a -> b) -> [a] -> [b] inter f [] = [] inter f l = map (uncurry f) $ zip l (tail l)
This is the same as
inter :: (a -> a -> b) -> [a] -> [b] inter f l = zipWith f l (tail l)
Except when l == [], but the second equation can be replaced by this nicer one.
Even then. :) (zipWith f l (tail l)) first tries to match l with pattern (a:as), and if that fails it will not touch its other argument (tail l).