【问题标题】:Calling Mathematica from OCaml program从 OCaml 程序调用 Mathematica
【发布时间】:2011-04-08 17:14:05
【问题描述】:

我正在编写 OCaml 代码。在其中一部分,我想检查两个算术表达式是否相等(如 x+2+y == x+2*y-y+2)。在mathematica 中实现这一点很简单,所以我只需要一些帮助来执行Mathematica 并在OCaml 中返回结果。我的操作系统平台是 Linux。

干杯, Z.

【问题讨论】:

    标签: ocaml wolfram-mathematica


    【解决方案1】:

    你也许可以使用类似这样的东西:

    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
    ...
    

    Documentation of open_process here

    Documentation of module Scanf here

    【讨论】:

      【解决方案2】:

      一个非常普遍的答案是编写一个命令行 Mathematica 脚本,它接受 2 个表达式(在命令行或标准输入)并输出它们是否相等。 然后在 OCaml 中只需通过系统调用调用该程序。

      至于写这样的命令行 Mathematica 脚本,我推荐 MASH(披露:我做了 MASH): Call a Mathematica program from the command line, with command-line args, stdin, stdout, and stderr

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-02-10
        • 2012-02-24
        • 1970-01-01
        • 2013-05-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-04-10
        相关资源
        最近更新 更多