Hello all -
I've been coding in Python for a couple of months now, and I recently ran across the following piece of code (where x is a set or list):
f = lambda x: [[y for j, y in enumerate(x) if (i >> j) & 1] for i in range(2**len(x))]
I was hoping someone could explain to me the following components:
1. 'y for j': after doing some reading, I think I understand the basic principles of * for *, but I still don't think I get exactly what Python is doing.
2. '(i >> j) & 1': I read something somewhere about shifting with '>>', but quite frankly, I'm still completely clueless. Also, I'm very new to bitwise operators and could use some explanation.