Timeline for Searching an object tree structure
Current License: CC BY-SA 3.0
7 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
May 7, 2014 at 3:11 | history | edited | Jamal | CC BY-SA 3.0 |
added 43 characters in body; edited tags; edited title
|
Jan 9, 2012 at 2:07 | history | migrated | from stackoverflow.com (revisions) | ||
Jan 7, 2012 at 14:48 | vote | accept | CommunityBot | ||
Jan 7, 2012 at 14:42 | comment | added | tokland |
side note: the functional abstraction for what you are doing is mapDetect (see gist.github.com/1222480 for a underscore implementation). In a lazy language it would be (head . filter predicate) .
|
|
Jan 6, 2012 at 19:18 | answer | added | thejh | timeline score: 6 | |
Jan 6, 2012 at 18:34 | comment | added | Elf Sternberg |
You could make the for a comprehension, but it wouldn't cut the visit short when a match was found, so while this is less "functional" it's just as good. The real test of code is this: which do you expect to be able to read six months from now? I'd remove the 'else', but that's my Haskell training talking: you've got a guard condition at the top of your function, not an alternative, but that's how I read things.
|
|
Jan 6, 2012 at 15:47 | history | asked | Matthew Nichols | CC BY-SA 3.0 |