axiom-developer
[Top][All Lists]
Advanced

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

[Axiom-developer] Expression problems


From: Hans Peter Würmli
Subject: [Axiom-developer] Expression problems
Date: Sun, 6 Nov 2005 22:19:33 +0100
User-agent: KMail/1.7.2

I am struggling with dealing with Expressions. For most sake and purposes I 
can find a fix and solve my small problems, but I never feel very assured. 

Maybe you can give me some pointers. The question that I originally would have 
liked to ask was: is there a "parse tree" object available for elements of 
type, say, Expression(Integer).

As there doesn't seem to exist a parse tree object, I should ask a different 
question: how are you analysing an Expression?

While browsing through the documentation I found many functions that could be 
usable for parsing, but I wasn't very lucky in using them. 

For example, there is a function

isMult(p) 

which is supposed to return [n,x] if p=n*x if n<>0.

For a Symbol x and an Integer n 

isMult(n*x) returns [n,x], 

but for another Symbol y

isMult(y*x) returns "failed".

Not exactly analoguously

isPower(x**y) returns [x**y,1], whereas

isPower(x**10) returns [x,10].

isExpt behaves like isPower, where isTimes differs from isMult and returns all 
factors of a product, i.e.

isTimes(x*y*z)=[x,y,z].

Whereas 

isPlus((x+y+z*y) returns [y z,y,x]

isTimes((x+y)*z) returns "failed" instead of the exp.

Somehow I don't understand the inner logic of these operations.

Any hints for how to proceed are greatly welcome.

Hans Peter




reply via email to

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