简体   繁体   中英

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. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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