FlaMM3R
FlaMM3R

Reputation: 67

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 :(

Upvotes: 0

Views: 100

Answers (1)

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

Upvotes: 7

Related Questions