On Friday, August 12, 2016 at 6:36:31 PM UTC+1, Waldek Hebisch wrote:
>
> Martin R wrote: 
> > 
> > given the continued interest in some features of fricas from some sage 
> > users, I had a look at the fricas interface in sage, and I'm thinking of 
> > improving it. 
> > 
> > The main question is: how can sage receive the output from fricas? 
> > 
> > currently, sage essentially sends "unparse(result:InputForm)" to fricas, 
> > and then parses the output: it strips away the prompt and the step 
> number 
> > and it looks for the type information, all using regular expressions. 
> > 
> > a first improvement I was thinking of is to use the ioHook to separate 
> the 
> > algebra output from the remaining information.  however, at least the 
> step 
> > number appearing just before the algebra output is currently not 
> decorated. 
> > 
> > is there a better way to get the results of computations - and also to 
> send 
> > instructions to fricas? 
>
> There are many ways.  Some issues were discussed few years 
> ago when Serge D. Mechveliani tried to create interface 
> between FriCAS and Haskell. 
>
> I suspect that you want to do little improvement as opposed 
> to major rewrite, so some ideas that _may_ be easy: 
>
> - using S-expressions to communicate with FriCAS.  On FriCAS 
>   side it is quite easy to generate textual form of S-expressions. 
>   S-expressions were designed to be easy to parse, so handling 
>   them on Python side should be easy too 
> - as Dima wrote Sage interface to Maxima works by putting Maxima 
>   in the same process as Sage.  This should be possible with 
>   FriCAS too.  I just checked that using Maxima build on to 
>   of sbcl and 'load-fricas.lisp' both FriCAS and Maxima seem 
>   to work in single process.  So it seems that small adjustment 
>   to build system should be enough 
>
> as far as the latter is concerned, most of the needed code is already in 
Sage;
namely, src/sage/interfaces/maxima_lib.py is basically an example of 
running Maxima in ECL, 
which is embedded in Python; for the latter the code is in 
src/sage/libs/ecl.pyx

In the latter one sees an example of calling CL functions from Sage:

        sage: from sage.libs.ecl import *
        sage: ecl_eval("(defun fibo (n)(cond((= n 0) 0)((= n 1) 1)(T (+ 
(fibo (- n 1)) (fibo (- n 2))))))")
        <ECL: FIBO>
        sage: ecl_eval("(mapcar 'fibo '(1 2 3 4 5 6 7))")
        <ECL: (1 1 2 3 5 8 13)>

That is, one would just need to adapt src/sage/interfaces/maxima_lib.py to 
loading/running FriCAS instead.
For this one needs to know some parts of FriCAS, that is, how to load it in 
a running CL instance, etc etc...

Dima


 

> -- 
>                               Waldek Hebisch 
>

-- 
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