by di456 · 3y ago · 0 comments
Scala was really nice for this syntax when I used it for Spark.
min(map(some_op, filter(some_filter, bar.baz()))).foo()
An alternative is also to use a generator comprehension that's identical to the inner part (in effect): min(some_op(item) for item in bar.baz() if some_filter(item)).foo()
Which could still be pulled out to a pair of lines for clarity: items = (some_op(item) for item in bar.baz() if some_filter(item)) # or some better name given a context
min(items).foo()