[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [Axiom-developer] I can't translate from the interpreter to thecompi
From: |
Page, Bill |
Subject: |
RE: [Axiom-developer] I can't translate from the interpreter to thecompiler |
Date: |
Tue, 28 Mar 2006 11:49:07 -0500 |
On Tuesday, March 21, 2006 3:48 PM Francois Maltey wrote:
>
> In the interpreter I have this single line :
>
> fct (n, x) == eval (real ((c + %i * s)^n), [c, s], [cos x, sin x])
>
> I want to add this function in manip.spad... :-(
> ...
On Tuesday, March 28, 2006 7:22 AM Martin Rubey wrote:
>
> I'd propose
>
> )abbrev package TEST Test
> Test(): Exports == Implementation where
>
> EXPR ==> Expression Integer
> CEXPR ==> Complex EXPR
> Exports == with
> fct: (Integer, EXPR) -> EXPR
> Implementation == add
> fct(n, x) ==
> vc := 'c::Symbol::EXPR
> vs := 's::Symbol::EXPR
> ve: EXPR := real((complex(vc,0)$CEXPR +
> complex(0,vs)$CEXPR)**n)
> eval(ve, [vs, vc], [sin(x)$EXPR, cos(x)$EXPR])
>
Here is another version of this package in SPAD that is a
little closer to the version that works in the interpreter:
--------
)abbrev package TEST Test
EXPR ==> Expression Integer
Test: with
fct:(Integer,EXPR)->EXPR
== add
c ==> coerce("c")$Symbol::EXPR
s ==> coerce("s")$Symbol::EXPR
import Complex EXPR
import List EXPR
fct(n:Integer, x:EXPR):EXPR ==
eval(real((complex(s,c))**n), [s, c], [sin(x), cos(x)])
---------
Using 'import' makes it shorter and easier to read.
Finally, here is the same thing in Aldor:
--------
#include "axiom"
#pile
EXPR ==> Expression Integer
c ==> coerce("c")$Symbol::EXPR
s ==> coerce("s")$Symbol::EXPR
import from Complex EXPR
import from List EXPR
fct(n:Integer, x:EXPR):EXPR ==
eval(real((complex(s,c))**n), [s, c], [sin(x), cos(x)])
--------
Regards,
Bill Page.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- RE: [Axiom-developer] I can't translate from the interpreter to thecompiler,
Page, Bill <=