I'm using Clojure and I'd really love to be able to use some of Mathematica's functions inside it. Can anyone help with mathlinking it?
|
|
To call Mathematica from Clojure, you will want to use Clojure's Java interop to access the Wolfram JLink classes to script Mathematica access. Start by launching Clojure with a classpath that includes the JLink.jar, for example with this batch file:
Once inside Clojure, use the Java interop syntax to access JLink classes as described in the tutorial Writing Java Programs that Use Mathematica. Typically this starts by launching a kernel with the MathLinkFactory to obtain a KernelLink:
Then discard the initial input packet from the kernel:
We can now perform evaluations of Mathematica code:
When retrieving results from an evaluation, you need to know what type to expect, or you need to retrieve the result as a string and parse it. Here's one way to evaluate a Mathematica expression that returns a list of integers and get the vector in Clojure:
There's also a presentation by Seth Chandler on connecting Mathematica to Clojure: J/Link without Java |
||||
|
|
|
I did not try it yet, but Clojuratica may be what you need. The project seems to no longer be maintained though (although I may be wrong). No idea how much of a problem this is, given changes in the Clojure since the time Clojuratica was released. Of course, Seth's talk was also great and is a great resource as well, as Joel mentioned. |
|||
|
|

