Re: Can I decompose a domain ?

William Sit <[email protected]>
Newsgroups gmane.comp.mathematics.axiom.general
Organization City College of New York
Message-ID <[email protected]>

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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.