def gMap(f, *gLists):
    """Generalized version of map() - work on infinite list
    
    Work differently from map(), stops when the end of the shortest
    gList is reached.
    
    """
    if f is None:
        f = lambda *x: x
    gLists = map(iter, gLists) # make sure it also works for ordinary list
    while 1:
        yield f(*[gl.next() for gl in gLists])
Generalized version of map() - work on infinite list
    
    Work differently from map(), stops when the end of the shortest
    gList is reached.
    
    
recipes/Python/170995_Manipulating_infinite_lists_implemented/recipe-170995.py