mardi 19 juillet 2016

haskell, pattern-matching on lists

i want to get the first element of every tuple which are stored in a list:

   INPUT: [(1,2,3), (1,4,5), (1,6,7)]

   searched OUTPUT : [(1,1,1)]

My Code:

f [] = []
f ((x,y,z):xs) = x:(f xs)

my output : [1,1,1]

Where is my misunderstanding / fallacy?

Aucun commentaire:

Enregistrer un commentaire