On Tue, 6 Apr 2010 21:56:37 +0100, Stephen Tetley <stephen.tet...@gmail.com> wrote: > Hello all > > > Having traversals with special behaviour for the first or last element > is useful for my current work: > > -- first element special > -- > anacrusisMap :: (a -> b) -> (a -> b) -> [a] -> [b] > anacrusisMap _ _ [] = [] > anacrusisMap f g (a:as) = f a : map g as
I think it makes for sense to not wire in the map function. firstOthers :: (a -> b) -> ([a] -> [b]) -> [a] -> [b] firstOthers _ _ [] = [] firstOthers f g (x:xs) = f x : g xs Then anacrusisMap is so short that we don't give it a name. anacrusisMap f = firstOthers f . map Same thing goes to the other one. Regards, -- Nicolas Pouillard http://nicolaspouillard.fr _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe