axiom-math
[Top][All Lists]
Advanced

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

Re: [Axiom-math] Can I decompose a domain ?


From: William Sit
Subject: Re: [Axiom-math] Can I decompose a domain ?
Date: Mon, 20 Mar 2006 19:53:04 -0500


Francois Maltey wrote:
> 
> Hello William, and thanks a lot
> 
> > > resFloat   : Expression Float := cos (4.0 * x)
> > > resInteger : Expression Float := cos (4 * x)
> > > resComplex : Expression Complex Integer := exp (3+4*%i)
> > >
> > > How can I get Float from resFloat ? Integer from resInteger, etc.
> > > in a *.input file ?
> 
> > Is the following what you want?
> 
> No I don't try to get the sub-argument, but the type of the subargument.
> But I'm not sure I can get it.
> 
[...]

> Imagine I know that a is an Expression...
> My function don't know if a is an Expression Float, or an Expression 
> Integer...
> 
> I want to do as below in an *.input file.
> 
> Myfunction (a : Expression ...) : String ==
>   is a an Expression Integer => "Integer"             -- or an other calculus.
>   is a an Expression Franction Integer => "Rationnal"
>   is a an Expression Complex ... => "Complex"   -- so I can use real and imag.
>   is a an Expression Float => "Float"
>   "A rare domain".
> 
> Thanks a lot.
> 
> Francois


This is a bit tricky, since any function in Axiom must have a specific domain as
source. The Axiom domain ANY is a coverall. Here is a try:

Myfunction(a:Any):String ==
  aDom := unparse ((domainOf a)::InputForm)
  substring?("Expression",aDom,1)=>delete(aDom, 1..11)
  "A rare domain"

To use the function, coerce the input to Any, such as:

Myfunction(resInteger::Any)


William




reply via email to

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