axiom-developer
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Axiom-developer] How to do generic sum using aldor?


From: Gernot Hueber
Subject: Re: [Axiom-developer] How to do generic sum using aldor?
Date: Thu, 04 Jan 2007 08:34:55 +0100

You also can use reduce. E.g. reduce(+, [1,2,3]) Gernot Ralf Hemmecke writes:
You should have read previous posts. Axiom does not understand "extend". The following code does what you want. Just say
%axiom
)co sumlist.as
sumlist [1,2,3]
---BEGIN sumlist.as
#include "axiom"
SumPackage(R: Ring): with {
    sumlist: List R -> R;
} == add {
     sumlist (l: List R): R == {
         s: R := 0;
         for x in l repeat  s:= s+x;
         return s
     }
}
---END sumlist.as
Have fun
Ralf

_______________________________________________
Axiom-developer mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/axiom-developer






reply via email to

[Prev in Thread] Current Thread [Next in Thread]