Lambda calculus expansions are cool.

Lambda calculus expansions are cool.

The reduceRight() array operator can be defined by pattern matching one of these two cases:

[ ].reduceRight(f, acc) → acc

[x, … xs].reduceRight(f, acc) → f(xs.reduceRight(f, acc), x)

i.e. An empty array right reduces simply to the value of its accumulator.

A non-empty array right reduces to its function being applied to a right reduction of its tail with its head being used as the accumulator.

Leave a comment