
19 Oct
2010
19 Oct
'10
11:23 p.m.
Suppose I would want to write a function rmap that acts like rmap [f,g,h] x == [f x, g x, h x] Do I gain any advantage or disadvantage (beside readability) from using rmap = flip $ map . flip id over rmap [] _ = [] rmap (f:fs) x = f x : rmap fs x ? I could imagine Haskell can optimize the first version better since it refers to the built in map function. But beside that, does Haskell struggle with the combinatory stuff in the first version? Or does it get optimized away? And how "expensive" are pattern matches on the other side, anyway? Thanks for reading, Bastian