Hi,

Maybe sending an R expression and getting an R expression back
for a 'suitable subset' of expressions is ok initially. Suitable could
cover 3 levels:

1) Mapping of names and standard functions, e.g. pi to Pi and
      sin(x) to Sin(x) etc.

2) It would be nice if we can use threading of functions, which will  
require
      converting R lists, vectors, matrices etc to yacas lists.

3) And finally, what about functions such as apply, quote, etc.?

Not sure how to get around the superfluous parse step when
calling an R function, e.g.  yacas(rExp). Rebuilding the original
argument to pass to yacas with reparse(substitute(rExp)) again
might again be ok initially.

Earlier I asked the question on where to do the back and forth
translation of R expressions to yacas statements. At that time I
focused on R or C++. The latter likely if its done using the
parsed tree.

Two other possibilities might be to 'redo' yacas to make yacas much
closer to R (examples that come to mind is all cases of sin(x) in R to
Sin(x) in yacas - as in 1) above -, although as  Gabor indicated, CForm
helps on the way back). The 2nd option is adding a whole bunch of Rules
to the yacas scripts to do this, e.g '10 # sin(x) <-- Sin(x)'. Not  
sure if
adding a special low level generic object to yacas would help here.

As rules in yacas are global, all of these substitutions could be  
collected
in 1 or a few yacas scripts read in when R's yacas function starts the
yacas_client.

I do work on Mac, have helped Simon and Stefano occasionally with
the Mac OS GUI.  If you have a yacas version as an Xcode project,  
that would
make playing around and trying some of above steps easier. I've  
looked at the
Mac OS GUI version of Yacas, seems based on an older version and  
vanilla 1.0.57
compiles fine on Mac OS. My guess is, if possible, we want a single  
approach
across the different platforms.

Rob


On Jul 17, 2005, at 8:29 AM, Ayal Pinkus wrote:

>> Using this instead of Tcl_Eval() gives some efficiency gain, but more
>> importantly, it avoids the "quoting hell" associated with the
>> construction of the relevant command strings.

> Interesting. You are not the first person asking this, actually.
>
> I chose for the C API as it is nice and clean, no name mangling issues
> while switching to a new gcc compiler, and it allows people to use it
> from C also. Back then, I thought all people would want to do is  
> send a
> string and receive one back.

>> Since both R and Yacas are "Lisp under the hood" languages (and Tcl
>> too for that matter), it is a fairly good guess that their parse  
>> trees
>> are similar, and that it would be a fairly simple task to translate
>> back and forth between them. Well, between suitable subsets, at  
>> least.
>> R's parse trees can in principle contain arbitrary R objects, but in
>> this context, we might only need constants, names, operators, and
>> function calls.

On Jul 15, 2005, at 6:25 AM, Peter Dalgaard wrote:

>> I wonder how difficult it would be to translate expressions back and
>> forth from R to yacas in either R or C++. And maybe strip 'In>'  
>> and 'Out>' like parts.
>
> You could also just do what those examples do and embed the whole
> enchillada in R. The slightly bad news is that the yacas_eval
> interface is text-based, which means that to handle an R expression
> via yacas you're going through a deparse-parse-operate-deparse-parse
> sequence. It would be nicer if you could just convert parse trees
> between the two languages. The good news is that there's a Lisp route
> (see example3), which should make the parser/deparser coding somewhat
> easier.

On Jul 15, 2005, at 3:44 AM, Gabor Grothendieck wrote:

> On 7/15/05, Rob J Goedman <[EMAIL PROTECTED]> wrote:
>
>> I wonder how difficult it would be to translate expressions back and
>> forth from R to yacas in either R
>> or C++. And maybe strip 'In>' and 'Out>' like parts.
>
> Not sure how generally this works but see my prior post:
>    http://tolstoy.newcastle.edu.au/R/help/04/03/1299.html

 > system("echo 'WriteString(CForm(Integrate(x)1/x))' | yacas_client")
In> WriteString(CForm(Integrate(x)1/x))
log(x)
Out> True
In>





        [[alternative HTML version deleted]]

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to