Comment

Comment by yummyfajitas

I don't get how map/filter is more flexible than list comprehensions. Map/filter require nesting:

    (filter (map expensive_call X) cond)
So do list comprehensions:

    [y for y in [expensive_call(x) for x in X] if cond(y)]
Near as I can tell, the only difference is that list comprehensions also provide a syntactic sugar for the convenience function filter_then_map. Sometimes this saves you a level of nesting, sometimes not.

Incidentally, this isn't even an issue in a pure functional language with sufficiently smart compiler.

parent yummyfajitas 17 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton