git » homepage.git » master » tree

[master] / archive / forums / hacker-news / raw / items / 3614550.json

{"by":"ax","id":3614550,"kids":[3614592,3614613,3614595,3614824,3614714,3614567,3616708,3614749],"parent":3614099,"text":"One bit of trouble I have with functional style programming is something like the following example: if I have an array of people with firstName and lastName properties, how would I go about returning the person with the longest full name without adding any properties directly to the objects? It is a simple map then reduce to return the maximum length, a fairly trivial modification thereof to return the full name, but when I want to return the original object, I can't think of a good way to do this.<p>The best I can figure is first mapping to a nested array where the first element is the object and the second is the computed property but that seems really messy. Thoughts?","time":1329783399,"type":"comment"}