mapreduce - native map and reduce tags

native_tags.contrib.mapreduce.do_map(func_name, *sequence)
Return a list of the results of applying the function to the items of

the argument sequence(s).

Functions may be registered with native_tags or can be builtins or from the operator module

If more than one sequence is given, the function is called with an argument list consisting of the corresponding item of each sequence, substituting None for missing values when not all sequences have the same length. If the function is None, return a list of the items of the sequence (or a list of tuples if more than one sequence).

Syntax:

{% map [function] [sequence] %}        
{% map [function] [item1 item2 ...] %}

For example:

{% map sha1 hello world %}

calculates:

[sha1(hello), sha1(world)]

This is a function tag.

native_tags.contrib.mapreduce.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

This is a function tag.

Read the Docs v: latest
Versions
latest
Downloads
PDF
HTML
Epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.