axiom-mail
[Top][All Lists]
Advanced

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

Re: [Axiom-mail] Generating rules in functions or macros


From: Themos Tsikas
Subject: Re: [Axiom-mail] Generating rules in functions or macros
Date: Wed, 30 Jul 2008 10:08:27 +0100
User-agent: KMail/1.9.6 (enterprise 20070904.708012)

On Wednesday 30 July 2008, Gerald Knizia wrote:
> How does the function F need to be defined such that the result of F(A,B)
> is equal to the one of
>    rule 'A == B
> and the result of F(C,D) is equal to
>    rule 'C == D


(1) -> F(x,y) == _rule(constant x, y)
                                                                   Type: Void
(2) -> F(A,B) (A+B+C+D)
   Compiling function F with type (Variable A,Variable B) ->
      RewriteRule(Integer,Integer,Expression Integer)

   (2)  D + C + 2B
                                                     Type: Expression Integer
(3) -> F(C,D) (A+B+C+D)
   Compiling function F with type (Variable C,Variable D) ->
      RewriteRule(Integer,Integer,Expression Integer)

   (3)  2D + B + A
                                                     Type: Expression Integer
(4) -> )sh PatternMatchAssertions
 PatternMatchAssertions  is a package constructor
 Abbreviation for PatternMatchAssertions is PMASS
 This constructor is exposed in this frame.
------------------------------- Operations --------------------------------
 assert : (Symbol,String) -> Expression Integer
 constant : Symbol -> Expression Integer
 multiple : Symbol -> Expression Integer
 optional : Symbol -> Expression Integer

PS: The underscore in _rule is there to override the special syntax of "rule" 
otherwise - it turns "rule" into accepting ordinary function syntax with 
brackets and list of arguments instead of the "lhs == rhs" syntax. The 
explicit "constant" function call delays the marking-as-constant of x to 
runtime, so it's the actual argument that gets marked instead of the symbol 
x. 

I've only used and maintained AXIOM for less than 10 years so I may be 
wrong :-)









________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. 
________________________________________________________________________




reply via email to

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