Hacker News new | past | comments | ask | show | jobs | submit login

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.



Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: