Reputation: 373
I am trying to get:
[(1,2),(3,4),(4,5)] = [1,3,4]
My attemp:
fun2 :: [(Int,Int)] -> [Int]
fun2 [] = []
fun2 ((a,b):ts) = **drop b**:fun2 ts --have problem here
Upvotes: 3
Views: 55
Reputation: 477676
You can map
with fst :: (a, b) -> a
:
fun2 :: [(a, b)] -> [a]
fun2 = map fst
or use pattern matching, like you already did:
fun2 :: [(a, b)] -> [a]
fun2 [] = []
fun2 ((a, _):ts) = a : fun2 ts
Upvotes: 2