In Haskell, I can easily map a list:
map (\x -> 2*x) [1,2]
gives me [2,4]
. Is there any "mapTuple" function which would work like that?
mapTuple (\x -> 2*x) (1,2)
with the result being (2,4)
.
Here's a rather short point-free solution:
import Control.Monad (join)
import Control.Arrow ((***))
mapTuple = join (***)