[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Axiom-mail] Generating rules in functions or macros
From: |
Gerald Knizia |
Subject: |
[Axiom-mail] Generating rules in functions or macros |
Date: |
Tue, 29 Jul 2008 05:09:16 +0200 |
User-agent: |
KMail/1.9.1 |
Hello,
I'd like to generate RewriteRules in macros or functions. For this some
parameters of the patterns need to depend on the macro/function arguments. I
was not able to find a syntax allowing for that.
Example: How to write a function returning a rule which replaces the variable
in its /function argument/ by Y?
o f(X) == (rule 'X == Y)
-> doesn't work, will only match a literal "X", regardless of function
argument. Gives f(a)(a) = a and f(a)(X) = Y.
o f(X) == (rule X == Y)
-> doesn't work, will match anyting as "X", regardless of function argument.
Gives f(a)(a) = Y and f(b)(a) = Y.
o In fact, this does not even seem to work when BasicOperators are passed as
function arguments:
f(X) == (rule X == Y)
T := operator 'T
then f(T)(cos(x)) still gives Y, although T is an operator and supposed to
stand for itself even when unquoted.
o Using something like f(Variable "a")(a) didn't seem to be allowed.
Is there some way to accomplish something like that? Am I missing something
important in they way axiom works? If using functions or macros above does
not seem to make any difference.
PS: The axiom user's guide and axiom programmer's guide at
http://www.axiom-developer.org/axiom-website/documentation.html both contain
8 pages and no content. Is this intended?
PPS: What I'm actually trying to do is to replace variables like "Op^n" by
actual operators which are composed:
Dx := operator 'Dx
Compose(op,n,expr) == if n = 0 then expr else op(Compose(op,n-1,expr))
ReplaceOps1(D1,D,expr) == (rule ?f * '(D1)^(?n) == Compose(D,n,f))(expr)
ReplaceOps1(D1x,Dx,D1x**2 * g)
ReplaceOps1(D1x,Dx,D1**2 * g)
The ops themselves are formed by some non-trivial algebra. And there are lots
of them, therefore I'd like to generate their (similar but non-identical)
substitution rules by macros or functions.
--
Gerald Knizia
- [Axiom-mail] Generating rules in functions or macros,
Gerald Knizia <=