import functools
import operator


def sequence(grammar, n):
    """
    Creates a grammar element that matches exactly N of the input
    grammar.
    """
    return functools.reduce(operator.add, [grammar] * n)