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

map and lambda predate list comprehensions, yes.

It's useful to have map as a first-class function that you can pass to another function:

    def operate_on_two_things(hof):
        return (hof([1, 2, 3], lambda x: x + 1),
          hof(("A", "B"), lambda y: y + "A")))

    operate_on_two_things(map)
(trivial example, but it hopefully makes the point - it's harder to do that with a list comprehension)


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

Search: