def map_bits(fn, n):
 while n:
  b = (n & ((~ n) + 1))
  (yield fn(b))
  n ^= b

def map_bits ( fn , n ) : while n : b = ( n & ( ( ~ n ) + 1 ) ) ( yield fn ( b ) ) n ^= b
call the given function given each nonzero bit from n .