After some sleep I decided to go for the simple thing first.  In 
particular, I want to restrict myself to fricas.  Here is a list of things 
todo on the sage side:

1) implement a method that (reliably!) yields a tuple (type, 1d algebra 
output, 2d algebra output, error message, etc) as strings.  1d algebra 
output should come in "unparsed inputform" as one very long string, I'd 
say.  2d algebra output should be empty if 1d output is available.

It should be able to deal with very long lines, too, possibly be using file 
io.  This involves use of ioHook and some regexps.

2) implement a method that translates fricas output into sage types.

I think this could work as follows: we want to map fricas types to sage 
constructors, possibly recursively.  Recall that what's really sent to 
fricas is something like "sage23 := [x^n/y^n for n in 1..3]", so that sage 
can access the result using the variable "sage23".  This string is referred 
to as self._name

Now what I propose is a method which takes a parsed type, e.g., "Integer" 
or ("List", "Integer") or 
("UnivariatePolynomial", "x", ("Fraction", "Integer"))

def to_sage(type):
    if type == "Integer":
         return to_sage_integer()
    elif type == "String":
         return to_sage_string()
    ...
    elif isinstance(type, tuple):
        if type[0] == "List":
            return to_sage_list(type[1])
        elif type[0] == "Fraction":
            return to_sage_fraction(type[1])
        ....

and so on.

So, if the type is ("List" ("Fraction" ("UnivariatePolynomial" "x" 
"Integer"))), this method would call

    to_sage_list(("Fraction" ("UnivariatePolynomial" "x" "Integer"))

which might be something like

def to_sage_list(self, type):
    n = fricas.eval("#" + self._name).to_sage_integer()
    return [fricas.eval(self._name + ".%n").to_sage(type) for n in 
range(1,n+1)]

I'm not sure whether this is clever.  What do you think?

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to