Home > OS >  Haskell - Remove elements in a list of tuples that are greater than n
Haskell - Remove elements in a list of tuples that are greater than n

Time:12-16

how would i remove elements in a list of tuples that are greater than n?

the list of tuples is like so: [("abcde",1),("fghi",5),("jklm",10)]

etc if i was to remove elements greater than 6:

 [("abcde",1),("fghi",5)]

CodePudding user response:

You could do it with filter and a lambda like so:

filter (\(a,b) -> b < 7 ) list
  • Related