From: "Peng Zhang" <pczhang@gmail.com>
To: caml-list@yquem.inria.fr
Subject: call ocaml from R
Date: Tue, 24 Jun 2008 22:17:17 -0400 [thread overview]
Message-ID: <6999988a0806241917p3d26a170s5ecfc8925e9d5e5d@mail.gmail.com> (raw)
Hi folks,
I need some help from you. What I want to do is that my main program
is in R and I want to implement part of it with ocaml.
The following is an example.
/* mysin.R */
dyn.load("mysin.so")
mysin <- function(x)
.C("mysin", as.double(x), r = double(1))$r
/* mycode.ml */
let sin_ml x = sin x
let _ = Callback.register "sin_ml" sin_ml
I want to use sin defined in mycode.ml in mysin.R
Then I write the following stub code
/* mysin.c */
#include <caml/mlvalues.h>
#include <caml/memory.h>
#include <caml/alloc.h>
#include <caml/custom.h>
#include <caml/callback.h>
void mysin(double * x, double * r){
value * closure_f;
caml_startup(NULL);
closure_f = caml_named_value("sin_ml");
*r = Double_val(caml_callback(*closure_f, caml_copy_double(*x)));
}
It isn't working right now. What I am not sure about is what to put in
caml_startup.
Can somebody help with me this? Thank you very much!
Best,
Peng
next reply other threads:[~2008-06-25 2:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-25 2:17 Peng Zhang [this message]
2008-07-03 15:21 ` Peng Zhang
2008-07-03 17:29 ` [Caml-list] " Ashish Agarwal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6999988a0806241917p3d26a170s5ecfc8925e9d5e5d@mail.gmail.com \
--to=pczhang@gmail.com \
--cc=caml-list@yquem.inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).