On 05/23/2007 06:50 PM, Bill Page wrote:
Quoting Martin Rubey <[EMAIL PROTECTED]>:
... Igor Khavkine writes:
Can someone explain this syntax? Looking at the Axiom .spad files,
I see that it has general usage +/[...some list construction...].
It is old syntax for reduce and should go away.
I very much agree. The reason is that one should give an initial value
otherwise you might be surprised.
woodpecker:~/scratch>aldor -fx -laldor aaa.as
woodpecker:~/scratch>aaa
Sum: 29
Prod: 0
But if you like the
f/[a,b,c]
syntax, you can actually define a similar things in Aldor. (I guess,
SPAD would be just the same.)
Ralf
---BEGIN aaa.as
#include "aldor"
#include "aldorio"
macro Z == Integer;
Pkg: with {
/: ((Z, Z) -> Z, List Z) -> Z;
} == add {
(f: (Z, Z) -> Z) / (l: List Z): Z == {
empty? l => 0;
f(first l, f/(rest l));
}
}
main(): () == {
import from Pkg;
l1: List Z := [2,4,6,8,3,5,1];
sum: Z := (+)/l1;
prod: Z := (*)/l1;
stdout << "Sum: " << sum << newline;
stdout << "Prod: " << prod << newline;
}
main();
---END aaa.as
_______________________________________________
Axiom-math mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/axiom-math