Probably what we need is some kind of recursive type constructor.
See for example:
http://www.cs.kent.ac.uk/people/staff/sjt/Atypical/AldorExs/vector.as
If you look closer to that, then you see that vector.as is implementing
"List" in a terribly complicated way.
Look at
-- Add up the entries of a Vector(n).
addVec(n:Integer,v:Vector(n)):Integer
== {
import from Record(fst:Integer,rst:Vector(n-1));
if n<=1
then 0
else vec.fst + addVec(n-1,vec.rst);
where { vec == (v pretend -- A
Record(fst:Integer,rst:Vector(n-1))); }};
in particular look at the argument. If it were a list you could forget
about the n, but here you have to give it. I am sure, nobody would ever
use such code.
If you must have a union over Vectors of arbitrary lenght then a cleaner
design would be to define vectors of lenght n and in a second step
define operations on vectors of different length.
In aldor-combinat you would define that thing like in the BinaryTree
example I gave before but just use the equation V = 1 + X * V.
And, by the way, I did not use "pretend" in my code.
Ralf
_______________________________________________
Axiom-developer mailing list
Axiom-developer@nongnu.org
http://lists.nongnu.org/mailman/listinfo/axiom-developer