[Haskell-cafe] Established names for a couple of list functionals?
stephen.tetley at gmail.com
Tue Apr 6 16:56:37 EDT 2010
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
-- last element special
cabooseMap :: (a -> b) -> (a -> b) -> [a] -> [b]
cabooseMap _ _  = 
cabooseMap f g (a:as) = step a as where
step x  = [g x]
step x (y:ys) = f x : step y ys
*Overlay1> anacrusisMap (+1) id [1..10]
*Overlay1> cabooseMap id (+1) [1..10]
My question (trivial, but still...) - is there any prior art naming
For the record, my name derivation is:
+ anacrusis - musical term, the pickup notes before the first bar in a score.
+ caboose - there was discussion on Haskell-Cafe a couple of months
ago about a list data type with a distinguished terminal type. Caboose
is the name I remember.
More information about the Haskell-Cafe