transform function with yield to return a generator function