On 03/12/2012 05:51 PM, Serge D. Mechveliani wrote:
I need to build (in Spad) an element x : (D : EuclideanDomain)
into SExpression.
The first question I would have: Why?
SExpression is losing all type information, as a FriCAS programmer, one
would think twice about the need of such a function.
I D is a EuclideanDomain, then there are no exported functions to turn
an element of D into SExpression. If you don't additionally require from
D that it exports a function foo: % -> SExpression, the only thing you
can do, is via (type unsafe) tricks.
Since everything in FriCAS is in the end something in LISP and
SExpression is the SPAD abstraction to LISP, the easiest solution for
d:D to be turned into an SExpression is
d pretend SExpression
But I am immediately withdraw that. Simply try
e := sin(x)
e pretend SExpression
((Now wait a few minutes with a huge expression running by and then
press Ctrl-C to abort this unfinished thing.))
So, in general, there is no way. At least none that I know of.
-----------------------------------------
)abbrev package FOO Foo
Foo(D : EuclideanDomain) : with
f : D -> SExpression
==
add
f x ==
xOF := coerce(x) :: OutputForm
xI := convert(xOF) $InputForm
xStr := unparse(xI) :: String
convert(xStr :: Symbol) $SExpression
What you are trying here loses all the structure of the expression. I'm
pretty sure that you don't want that.
Again: What is your overall goal here?
I suspect that all such questions about improving the compiler need to be
consdered in the frame of Aldor, and one could write things in Aldor,
with using the FriCAS library.
(?)
Currently, that should work. See INSTALL.aldor and remove the first line
of that file. It is erroneously still saying that the aldor interface
doesn't work. At least if you have FriCAS 1.1.6, then it should work.
But Aldor won't help you with conversion into SExpression. I would even
say that it is more strict than SPAD wrt. types.
But
a) I do not know, of whether Aldor is currently workable in this mode,
b) it seems, there are some problems with openness and license.
Right. You have seen my monthly mails to Stephen Watt. Unfortunately,
the last mail I got from him is from June 15, 2011. Maybe we should
renew the FreeAldor petition on the Axiom-Wiki.
Ralf
--
You received this message because you are subscribed to the Google Groups "FriCAS -
computer algebra system" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/fricas-devel?hl=en.