haskell - Summing a list of tuples -


i have list of tuples containing intergers.

[(123,123,123),(123,123,123),(123,123,123)] 

i want sum of second values of list eg;

[(_,123,_),(_,123,_),(_,123,_)] 

123 + 123 + 123

i think should using fold im not sure

extract second value list of tuple list new list , sum new list.

prelude> let = [(123,123,123),(123,123,123),(123,123,123)] prelude> sum [i | (_,i,_) <- a] 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -