Govind Parmar
Govind Parmar

Reputation: 21532

List to list of tuples in haskell?

In Haskell, say I have a list of Ints, which I know is of a length that is a multiple of 4.

How might I write a function that changes the list into a list of (Int, Int, Int, Int) tuples instead?

Eg:

int2tuplelist :: [Int] -> [(Int, Int, Int, Int)]

Upvotes: 0

Views: 165

Answers (1)

Kl232
Kl232

Reputation: 76

int2tuplelist (x1:x2:x3:x4:xs) = (x1,x2,x3,x4): int2tuplelist xs
int2tuplelist []               = []

Upvotes: 4

Related Questions