lratsubst SciMax Toolbox lriem

SciMax Toolbox >> lreduce

lreduce

Maxima Function

Calling Sequence

lreduce (F, s)
lreduce(F,s,s_0)

Description

Extends the binary function F to an n-ary function by composition, where s is a list.

lreduce(F, s) returns F(... F(F(s_1, s_2), s_3), ... s_n). When the optional argument s_0 is present, the result is equivalent to lreduce(F, cons(s_0, s)).

The function F is first applied to the leftmost list elements, thus the name "lreduce".

See also , , and .

Examples:

lreduce without the optional argument.

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

lreduce with the optional argument.

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

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

(%i1) lreduce ("^", args ({a, b, c, d}));
                               b c d
(%o1)                       ((a ) )
(%i2) lreduce ("//", args ({a, b, c, d}));
                                a
(%o2)                         -----
                              b c d
lratsubst SciMax Toolbox lriem