I have just started writing lambdas in python these days and I wonder whether there's a good way to avoid chaining map/reduce/filter (which causes confusion when closing parenthesis).
Here's a lambda which chains a few level:
a = [1,2,3,4,5,6]
b = [1,0,0,1,0,1]
reduce(lambda x,y:x+y,map(lambda x:a[x],map(lambda x:x[0],filter(lambda (i,x):x==0,enumerate(b))))) # returns 10,2+3+5 where corresponding elements in array b is 0
I still prefer old-school style of OOP like
x.dosomething().doanotherthing().dofoo().dobar()
which make things easier to read for me. Besides defining these as other function variable which causes intermediate results to be calculated, are there any inline ways (that avoid intermediate results to be calculated). How can I do this?