map
and filter
are often interchangeable with a list, but reduce
not as easy to replace as map
and filter
(and, in addition, in some cases I still prefer the functional syntax), However, when you need to work with the arguments themselves, I am in syntactic gymnastics and, ultimately, must write entire functions to ensure readability.
I use map
so that a simple and straightforward block test is simple, but please keep in mind that practical use cases may be more difficult to express as a list comprehension.
I found two messy ways around this, but I wouldn’t really use anything.
[afunc(*i) for i in aniter] == map(afunc, *zip(*aniter)) [afunc(*i) for i in aniter] == map(lambda i: apply(afunc, i), aniter)
Is there any discerning, elegant way to express the right side of these expressions?
source share