The Maxima on-line user's manual

Algebra Calculator

Rreduce

Function: rreduce (<F>, <s>)

Function: rreduce (<F>, <s>, <s_{n + 1}>) Extends the binary function <F> to an n-ary function by composition, where <s> is a list.

`rreduce(<F>, <s>)` returns `F(s_1, ... F(s_{n - 2}, F(s_{n - 1}, s_n)))`. When the optional argument <s_{n + 1}> is present, the result is equivalent to `rreduce(<F>, endcons(<s_{n + 1}>, <s>))`.

The function <F> is first applied to the rightmost list elements, thus the name "rreduce".

See also `lreduce`, `tree_reduce`, and `xreduce`.

Examples:

`rreduce` without the optional argument.

```          (%i1) rreduce (f, [1, 2, 3]);
(%o1)                     f(1, f(2, 3))
(%i2) rreduce (f, [1, 2, 3, 4]);
(%o2)                  f(1, f(2, f(3, 4)))```

`rreduce` with the optional argument.

```          (%i1) rreduce (f, [1, 2, 3], 4);
(%o1)                  f(1, f(2, f(3, 4)))```

`rreduce` applied to built-in binary operators. `/` is the division operator.

```          (%i1) rreduce ("^", args ({a, b, c, d}));
d
c
b
(%o1)                         a
(%i2) rreduce ("/", args ({a, b, c, d}));
a c
(%o2)                          ---
b d```

```(%o1)                                true
(%i2) ```

Related Examples

? rreduce;

Calculate

rreduce

rreduce(f,[1,2,3]);

Calculate

rreduce

rreduce(f,[1,2,3,4]);

Calculate

rreduce

f(x,y):=10*x+y;

rreduce(f,[1,2,3]);

Calculate

? rreduce;

Calculate

rreduce

rreduce(f,[1,2,3]);

Calculate

rreduce

rreduce(f,[1,2,3,4]);

Calculate

rreduce

f(x,y):=10*x+y;

rreduce(f,[1,2,3]);

Calculate