Call Mathematica from OCaml

I am writing OCaml code. In its part, I want to check if two arithmetic expressions are equal (for example, x + 2 + y == x + 2 * yy + 2). The implementation of this in mathematics is simple, so all I need to do is run Mathematica and return the result to OCaml. My OS platform is Linux.

Cheers, Z.

+3
source share
2 answers

You can use something line by line:

let channel_to_mathematica, channel_from_mathematica = open_process "mathematica"
in
Printf.fprintf channel_to_mathematica "Tell me if this is equal ...\n";
let answer_from_mathematica = Scanf.fscanf channel_from_mathematica ... 
in
...

Open_process documentation here

Scanf module documentation here

+3
source

- Mathematica script, 2 ( , stdin) , . OCaml .

Mathematica script, MASH (: MASH): Mathematica , stdin, stdout stderr

+3

Source: https://habr.com/ru/post/1763429/


All Articles