axiom-developer
[Top][All Lists]

## [Axiom-developer] 20080904.01.tst.patch (add reduce example (Tsikas))

 From: daly Subject: [Axiom-developer] 20080904.01.tst.patch (add reduce example (Tsikas)) Date: Thu, 4 Sep 2008 05:13:37 -0500

```add an example for reduce to the output of )d op reduce
======================================================================
diff --git a/changelog b/changelog
index 056933f..d6cf2ec 100644
--- a/changelog
+++ b/changelog
@@ -1,3 +1,4 @@
20080901 tpd src/input/Makefile add start of multivar poly tests
20080901 tpd src/input/bini.input add start of multivar poly tests
20080831 tpd src/algebra/algfact.spad graphviz dotfile decoration
index 7212a34..d137a42 100644
@@ -313,9 +313,14 @@ Collection(S:Type): Category == HomogeneousAggregate(S)
with
if % has finiteAggregate then
reduce: ((S,S)->S,%) -> S
++ reduce(f,u) reduces the binary operation f across u. For example,
-       ++ if u is \axiom{[x,y,...,z]} then \axiom{reduce(f,u)} returns
\axiom{f(..f(f(x,y),...),z)}.
+       ++ if u is \axiom{[x,y,...,z]} then \axiom{reduce(f,u)}
+        ++ returns \axiom{f(..f(f(x,y),...),z)}.
++ Note: if u has one element x, \axiom{reduce(f,u)} returns x.
++ Error: if u is empty.
+        ++
+        ++C )clear all
+        ++X reduce(+,[C[i]*x**i for i in 1..5])
+
reduce: ((S,S)->S,%,S) -> S
++ reduce(f,u,x) reduces the binary operation f across u, where x is
++ the identity operation of f.

```