# Path: native_tags/decorators.py
# def tag(bucket, doc):
#     def wrapped(inner, **options):


from native_tags.decorators import function
    from native_tags.registry import register
    import operator
    if len(sequence)==1:
        sequence = sequence[0]
    return map(get_func(func_name, False), sequence)
do_map = function(do_map, name='map')
do_map.test = {'args':('ord','wtf'),'result':[119, 116, 102]}

def do_reduce(func_name, *sequence):
    """
    Apply a function of two arguments cumulatively to the items of a sequence,
    from left to right, so as to reduce the sequence to a single value.
    
    Functions may be registered with ``native_tags`` 
    or can be ``builtins`` or from the ``operator`` module
    
    Syntax::
    
        {% reduce [function] [sequence] %}        
        {% reduce [function] [item1 item2 ...] %}
    
    For example::
    
        {% reduce add 1 2 3 4 5 %}
        
    calculates::
    
        ((((1+2)+3)+4)+5) = 15
    """
    if len(sequence)==1:
        sequence = sequence[0]
    return reduce(get_func(func_name), sequence)

# Path: native_tags/decorators.py
# def tag(bucket, doc):
#     def wrapped(inner, **options):


# Path: native_tags/contrib/mapreduce.py
from native_tags.decorators import function
    from native_tags.registry import register
    import operator

    if len(sequence)==1:
        sequence = sequence[0]
    return map(get_func(func_name, False), sequence)
do_map = function(do_map, name='map')
do_map.test = {'args':('ord','wtf'),'result':[119, 116, 102]}

def do_reduce(func_name, *sequence):
    """
    Apply a function of two arguments cumulatively to the items of a sequence,
    from left to right, so as to reduce the sequence to a single value.
    
    Functions may be registered with ``native_tags`` 
    or can be ``builtins`` or from the ``operator`` module
    
    Syntax::
    
        {% reduce [function] [sequence] %}        
        {% reduce [function] [item1 item2 ...] %}
    
    For example::
    
        {% reduce add 1 2 3 4 5 %}
        
    calculates::
    
        ((((1+2)+3)+4)+5) = 15
    """
    if len(sequence)==1:
        sequence = sequence[0]
    return reduce(get_func(func_name), sequence)

do_reduce = function(do_reduce, name='reduce')