axiom-mail
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Axiom-mail] Declare variable type within function


From: Angelos Mantzaflaris
Subject: [Axiom-mail] Declare variable type within function
Date: Mon, 17 Mar 2008 08:40:47 +0200

Hello,

Here is a newbie question: I am writing some axiom scripts for which I don't
want to declare I/O types. But, I need to declare, for example, an empty
list of typeOf(input). I have tried the following:

foo(x)==
        L:=[]
        L:= append(L,x)
        return L

Axiom will complain:
The type of the local variable L has changed in the computation.
We will attempt to interpret the code. I also try:

foo(x)==
        L:=[]::typeOf(x)
        L:= append(L,x)
        return L

Axiom will complain again:
Cannot compile conversion for types involving local variables.
In particular, could not compile the expression involving :: typeOf
AXIOM will attempt to step through and interpret the code.

But I can play tricks like this:

foo(x)==
        L:=[x.1-x.1]
        L:= append(L,x)
        return L

And Axiom will compile the function without errors:
Compiling function foo with type List PositiveInteger List Integer


So my question is, how can I do this in a straightforward way (without
playing tricks)?

Thank you in advance,
Angelos






reply via email to

[Prev in Thread] Current Thread [Next in Thread]