[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Axiom-developer] How to do generic sum using aldor?
From: |
Ralf Hemmecke |
Subject: |
Re: [Axiom-developer] How to do generic sum using aldor? |
Date: |
Thu, 04 Jan 2007 16:10:38 +0100 |
User-agent: |
Thunderbird 1.5.0.9 (X11/20061206) |
Since you want to work with Axiom, I guess you are right here.
well, there is also axiom-math and axiom-mail ... anyways the people who
answer seem to be the same:)
Right. There are not so many people anyway. And your question is not
only related to Math but it goes a bit deeper.
I currently rather rely on what is provided in LibAldor+LibAlgebra and
don't take things from LibAxiom, but that is personal taste.
I wasn't aware that this is possible.
Using #include "aldor" and #include "algebra" compiles but won't run:
(1) -> sum [1,2,3]
>> System error:
AxiomXL file "sal_list" is missing!
how can one mix axiom and libaldor?
I don't mix. You misunderstood. I for my taste find the libraries coming
with Aldor cleaner. And even though they have much less functionality,
it is sufficient for me. Sooner or later the Axiom library has to be
redesigned anyway, because the files should become literate documents
and all mis-design should go away. But that is a lot of work and
certainly not finished tomorrow.
Anyway, you have to use
#include "axiom"
if you want to use your things inside an Axiom session (which is not
primarily my goal).
Yep. But sorry to say: Axiom is weak in that respect (at least to my
knowledge).
ok, at least this is an answer and I shall not try further.
Well, somebody should make Generator available in Axiom. ;-)
Actually, making Generator available is easy, but still that is not
enough. Axiom does not allow a Generator in a for expression so
g: Generator X := someAldorFunctionThatReturnsAGenerator()
for x in g repeat doSomething(x)
won't work. One can even work around a little as has been demonstrated
by Martin Rubey...
http://sourceforge.net/mailarchive/message.php?msg_id=37824208
Look into
svn://svn.risc.uni-linz.ac.at/hemmecke/combinat/trunk
directory combinat/src/axiom-compatibility/axcompat*.as.nw
in order to see how Generator is made available.
In fact Aldor-Combinat is developed on libaldor+libalgebra, but by this
files in "axiom-compatibility" we provide some wrapper function to make
(nearly) the same code also compiling with libaxiom and thus available
in Axiom.
Thus my "SumPackage" includes also
sum ( ll: Stream R) : R == {
import from StreamFunctions2(R,R);
last complete scan(0,+, ll);
}
Is it really true that StreamFunctions2 must explicitly be imported?
StreamFunctions2 is a package. How else would the compiler find out that
you want to use a function from that package?
The "last complete scan" makes me worry if the stream is really long
and all intermediate results are stored; or is it optimized away by the
compiler?
I don't think the compiler can optimize that away.
But in StreamAggregate you also find the exports
frst: % -> S
++ frst(s) returns the first element of stream s.
++ Caution: this function should only be called after a
\spad{empty?} test
++ has been made since there no error check.
rst: % -> %
++ rst(s) returns a pointer to the next node of stream s.
++ Caution: this function should only be called after a
\spad{empty?} test
++ has been made since there no error check.
There is also first and rest, but don't ask me which one you should use,
I have no idea.
I rather would like the for loop but do not know where to import it from.
greping the source files is not really helpful in this case ...
Use a while loop a la...
s: R := 0;
while not empty? ll repeat {
s := s + first ll;
ll := rest ll;
}
Hope that helps
Ralf