简体   繁体   English

如何获取 Haskell 列表中的元组数

[英]How to get the number of tuples in a list in Haskell

i want to get the sum of tupples in a list.我想得到一个列表中元组的总和。 for an example举个例子

[("Isuru1","Ranasinghe1",123),("Isuru2","Ranasinghe2",123),("Isuru3","Ranasinghe3",123),("Isuru4","Ranasinghe4",123)]

in above list the answer has to be 4. please help me to solve this.在上面的列表中,答案必须是 4。请帮我解决这个问题。 i am new to haskell:(我是 haskell 的新手:(

Use the length function.使用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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM