[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Axiom-math] What is the "+/" operator?
From: |
Ralf Hemmecke |
Subject: |
Re: [Axiom-math] What is the "+/" operator? |
Date: |
Wed, 23 May 2007 19:13:46 +0200 |
User-agent: |
Thunderbird 2.0.0.0 (X11/20070326) |
On 05/23/2007 06:50 PM, Bill Page wrote:
Quoting Martin Rubey <address@hidden>:
... 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] What is the "+/" operator?, Igor Khavkine, 2007/05/23
- Re: [Axiom-math] What is the "+/" operator?, Martin Rubey, 2007/05/23
- Re: [Axiom-math] What is the "+/" operator?, Bill Page, 2007/05/23
- Re: [Axiom-math] What is the "+/" operator?,
Ralf Hemmecke <=
- Re: [Axiom-math] What is the "+/" operator?, Bill Page, 2007/05/23
- Re: [Axiom-math] What is the "+/" operator?, Gabriel Dos Reis, 2007/05/23
- Re: [Axiom-math] What is the "+/" operator?, Ralf Hemmecke, 2007/05/23
- Re: [Axiom-math] What is the "+/" operator?, Gabriel Dos Reis, 2007/05/23
- Re: [Axiom-math] What is the "+/" operator?, Ralf Hemmecke, 2007/05/24
- Re: [Axiom-math] What is the "+/" operator?, Gabriel Dos Reis, 2007/05/24
- Re: [Axiom-math] What is the "+/" operator?, Gabriel Dos Reis, 2007/05/23
Re: [Axiom-math] What is the "+/" operator?, Gabriel Dos Reis, 2007/05/23