11 ms·
In Haskell there are some helper functions for these: longestLastname :: [Person] -> Person longestLastname names = maximumBy (comparing (length . last
by eru 15y ago
In Haskell there are some helper functions for these:
longestLastname :: [Person] -> Person
longestLastname names = maximumBy (comparing (length . lastname)) names
In general, you can do map something like
extractProperty list = map (\x -> (f x, x)) list
Then work on the first element of the tuple (comparing for sorting etc), and at the end return the original object by extracting the second element of the tuple.