The lower value from a tuple of words and values in haskell
问题 I'm trying to write a function that chooses the tuple with the lower value and the tuple is formed by a word and a value. For example, for a list of tuples like this one: [("CHURCH",262),("PENCIL",311),("FLOUR",175),("FOREST",405),("CLASS",105)], the function would return ("CLASS",105) Can someone help me out? :) Thank you so much! 回答1: Try this: foldl1 (\acc x -> if snd x < snd acc then x else acc) <your list> You fold your list by comparing the current element of the list to the next one.