human
Complete this python program:
def chain(*brules):
assistant
#Here is the Python code you requested.

    """Compose a sequence of brules so that they apply to the expr sequentially
    """
    def chain_brl(expr):
        if (not brules):
            (yield expr)
            return
        (head, tail) = (brules[0], brules[1:])
        for nexpr in head(expr):
            for nnexpr in chain(*tail)(nexpr):
                (yield nnexpr)
    return chain_brl