Haskell - mapping the odd placed values and the even placed values differently

Posted by Abstract on Stack Overflow See other posts from Stack Overflow or by Abstract
Published on 2010-05-31T07:45:27Z Indexed on 2010/05/31 8:12 UTC
Read the original article Hit count: 222

Filed under:
|

Hey guys,

is there an easy way. To take a list of numbers, say 123456. Then multiply the odd placed by three and the even placed by 1.

i.e. (1 * 3) + (2 * 1) + (3 * 3) + (4*1) + (5*3) + (6*1)

i was thinking the map function somewhere along the lines. But i don't know how to map *3 to just the odd placed values. Oh and if you could give me the version not in prelude that would be great like the actual function or functions, as if its being imported from an external haskell file

Thanks for the help

© Stack Overflow or respective owner

Related posts about haskell

Related posts about mapping