
13 Apr
2005
13 Apr
'05
9:45 a.m.
I'm trying to write a function that combines folding and mapping
a map is a fold:) idList = foldr (:) [] map f = foldr ((:) . f) []
foldmap :: (b -> b -> b) -> (a -> b) -> [a] -> b foldmap f m = foldr1 f . map m
alternatively, and dealing with empty lists as well foldmap op n f = foldr (op . f) n cheers, claus