开发者

How to get the number of tuples in a list in Haskell

开发者 https://www.devze.com 2023-03-12 18:37 出处:网络
i want to get the sum of tupples in a list. for an example [(\"Isuru1\",\"Ranasinghe1\",123),(\"Isuru2\",\"Ranasinghe开发者_高级运维2\",123),(\"Isuru3\",\"Ranasinghe3\",123),(\"Isuru4\",\"Ranasinghe4

i want to get the sum of tupples in a list. for an example

[("Isuru1","Ranasinghe1",123),("Isuru2","Ranasinghe开发者_高级运维2",123),("Isuru3","Ranasinghe3",123),("Isuru4","Ranasinghe4",123)]

in above list the answer has to be 4. please help me to solve this. i am new to haskell :(


Use the length function. It gets the length of any list, no matter what's in it.

Example:

Prelude> length [("Isuru1","Ranasinghe1",123),("Isuru2","Ranasinghe2",123),("Isuru3","Ranasinghe3",123),("Isuru4","Ranasinghe4",123)]
4
0

精彩评论

暂无评论...
验证码 换一张
取 消