[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Axiom-developer] Re: [Axiom-math] (no subject)
From: |
Ralf Hemmecke |
Subject: |
[Axiom-developer] Re: [Axiom-math] (no subject) |
Date: |
Mon, 20 Jun 2005 16:11:42 +0200 |
User-agent: |
Mozilla Thunderbird 1.0 (X11/20041206) |
> (7) I tried using a list to return multiple variables from a
> function. However, this turns out to be of type any. These variables can be
> displayed but not used in operations any further. This means that you have
> to remember the types of each variable in the list. Then, manually in the
> calling function extract and explicitly typecast each variable in the
> returned list. Is there an easier way of doing this ??
I am somehow surprised that Axiom cannot work with multivalues.
(1) -> foo(a: Integer, b: Integer): (String, Integer) == ("sum", a+b);
The constructor Tuple takes 1 argument and you have given 2 .
(1) -> foo: (Integer, Integer) -> (String, Integer)
The constructor Tuple takes 1 argument and you have given 2 .
In Aldor the following program works just fine.
Ralf
------------ multi.as -------------------------------------
-- Run the program via
-- aldor -grun -laldor multi.as
-- and get the output
--: We call the function foo
--: foo(7, 11) = (Sum, 18)
#include "aldor"
#include "aldorio"
import from Integer;
foo(a: Integer, b: Integer): (String, Integer) == ("Sum", a+b);
main(): () == {
stdout << "We call the function foo" << newline;
(s, c) := foo(7, 11);
stdout << "foo(7, 11) = (" << s << ", " << c << ")" << newline;
}
main();