Reputation: 650
So I am passing a 3 tuple list into this function and want to return the first and third element of that tuple, why doesn't the code here work?
remove :: (a, b, c) -> (a,c)
remove (x, _, y) = (x,y)
The error I get is
*** Expression : remove (sortScore b h)
*** Term : sortScore b h
*** Type : [(Val,Int,End)]
*** Does not match : (a,b,c)
Upvotes: 1
Views: 1153
Reputation:
You need to use map
to transform each tuple in list sortScore b h
:
map remove $ sortScore b h
You can't apply remove
just to sortScore b h
because the last one is a list but remove
works on tuples.
Upvotes: 0
Reputation: 12070
sortScore
is returning a list of 3-tuples, but remove
only accepts one.
You can use map
to apply remove
to each element returned from sortScore
map remove (sortScore b h)
Upvotes: 3