Run Racket Code in R

Is there a way to run Racket code from R (R script call Racket code)?

I looked at Rseek and other sources without any pointers.

+4
source share
1 answer

A similar question arose recently on the Racket mailing list, and someone posted a link to an old thread where Matthew Flatt suggested starting the subprocess and pipelines .

It seems that Julia does not provide an external interface (for example, to call Julia from C). So, I think that you will have to manage Julia in a separate process through process or subprocess and communicate with the process through stdin and stdout.

Wed, Jan 29 2014 16:58:29 -0800 (PST), E Comer wrote:

Hi, developers, programmers and users of Racket:

Is there a way to call the Julia function from DrRacket? [I am trying to integrate Julia’s number of crunchy features with beautiful graphics in the plot module in Racket, to study some properties of specific dynamic systems]

Thanks so much for your support.

Enrique

So, for example, write a small Racket program that loops around: read from stdin, write the result to stdout. The format of what he reads and writes is up to you. He could read s-expressions (conveniently in Racket) and output a linearly oriented result (perhaps more convenient in R, I don’t know).

Then R run the Racket program as a subprocess and talk to its stdin and stdout.

For one example of the opposite (having a Racket channel for a subprocess), see this Racket client talking to this sub-process "server" in Python . I don't know if R has something like a Racket process , which gives you the stdin and stout subprocess.

Although FFI looks like the “right” approach, it can actually be difficult to marshal between high-level languages. This is often unnecessary when you have a certain intelligence in mind. My advice is to start by approaching the pipeline to the subprocess. It is generally simple and reliable. It may be fast enough for your needs. Sometimes it’s even faster. [one]


[1]: Like some anecdata, take a look at the Python GitHub story written in Python in their Ruby code. At one point, they had a rather complicated approach to implementing Python in Ruby. To make it faster, they switched to executing Pyigs in the subprocess and pipelines. (This is my understanding from the history of fixation, anyway.)

+9
source

All Articles