Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The "real functional" map/reduce/filter functions tend to be discouraged by programmers and linters too. It is becoming (has become?) an established part of the culture -- "Lambda in a `map`? Use a list comprehension instead."

I guess it's a "sheep as a lamb" thing -- "The 'functional way' is either points-free or pointless."

Maybe it's better in Rust because the method-style `x.filter().map().reduce()` lets you read left-to-right, and the "global function" `reduce(map(filter(x)))` has to be read inside-out. If there is a good reason to do Python's global function way, maybe D's UFCS can bring them the best of both worlds.



It is becoming (has become?) an established part of the culture -- "Lambda in a `map`? Use a list comprehension instead."

Which is annoying, because there are times when using map or filter is cleaner; for example, if you're doing pipeline-y stuff, using the function-based approach is much easier to read and reason about than doing a bunch of nested comprehensions.

I also tend to think people don't use itertools enough. But it catches people by surprise enough that several of my messing-with-interviewers canned solutions to common problems make heavy use of itertools (including a FizzBuzz which contains no 'for' or 'if' statements).




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

Search: