Declare variable type within function
"Angelos Mantzaflaris" <[email protected]>
| Newsgroups | gmane.comp.mathematics.axiom.user |
|---|---|
| Message-ID | <[email protected]> |
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