function reduce(accumulator = initial, variable IN list | expression)

To run an expression against individual elements of a list, and store the result of the expression in an accumulator, you can use reduce(). It will go through a list, run an expression on every element, storing the partial result in the accumulator. It works like the fold or reduce method in functional languages such as Lisp and Scala.

Arguments:
accumulator: A variable that will hold the result and the partial results as the list is iterated
initial: An expression that runs once to give a starting value to the accumulator
list: An expression that returns a list
variable: The closure will have a variable introduced in its context. Here you decide which variable to use.
expression: This expression will run once per value in the list, and produces the result value.

Example Query:
    MATCH p=(a)-->(b)-->(c)
    WHERE a.name='Alice' AND b.name='Bob' AND c.name='Daniel'
    RETURN reduce(totalAge = 0, n IN nodes(p)| totalAge + n.age) AS reduction