It is possible to call R from within Prolog, using a library recently implemented in SWI and YAP Prolog variants.
Reciprocally, is there any way of calling Prolog from within R ? In the absence of a direct R - Prolog interface capable of binding Prolog terms to R just as Rcpp binds C++ objects to R objects, is there any indirect way to achieve this aim (like calling Prolog from C++ code embedded in R code via Rcpp)?
By ’calling’, I mean ’linking’ prolog terms to R objects, as is possible for C++ objects using Rcpp, and executing prolog queries through R function wrappers, without resorting to operating system calls.
In SWI-Prolog and YAP you can use library real, written by Nicos Angelopoulos and Vitor Costa Santos.
With this library it is not only possible to call R from within Prolog, but you can even share datastructures between Prolog and R (e.g., Prolog lists <-> R matrices)!
An earlier version was published at PADL 2013. The current version uses some of the recent changes in SWI7, e.g. use of the dot for function application, to make the integration between SWI-Prolog and R even more seamless.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With