This is not an "alternative" to lambda, but rather a syntactic sugar for this particular use. There are other use cases of lambda, not expressible by this "alternative" syntax.
Further, the current lambda syntax is closer to those employed by other (purer) functional programming languages. Changing the current syntax is not a good idea.
This is not an "alternative" to lambda, but rather a syntactic sugar for this particular use. There are other use cases of lambda, not expressible by this "alternative" syntax.
My point is that in those other use cases are probably places you shouldn't be using lambda at all. For e.g. a bad use case for lambda might be:
avg = lambda lst: sum(lst) / len(lst)
This should be written as a def instead. But if you have good use cases of lambda, then I'd like to see them.
27
u/vph Jul 13 '11
bad idea.
This is not an "alternative" to lambda, but rather a syntactic sugar for this particular use. There are other use cases of lambda, not expressible by this "alternative" syntax.
Further, the current lambda syntax is closer to those employed by other (purer) functional programming languages. Changing the current syntax is not a good idea.