Book Image

Clojure Data Analysis Cookbook - Second Edition

By : Eric Richard Rochester
Book Image

Clojure Data Analysis Cookbook - Second Edition

By: Eric Richard Rochester

Overview of this book

Table of Contents (19 chapters)
Clojure Data Analysis Cookbook Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Evaluating Mathematica scripts from Clojuratica


Calling single functions is good and very useful, but sometimes we might have a number of operations in a file that we want to call from Clojure. Clojuratica allows you to do this as well.

Getting ready

First, we must have Clojuratica and Mathematica talking to each other. Either complete the Setting up Mathematica to dalk to Clojuratica for Mac OS X and Linux recipe or the Setting up Mathematica to talk to Clojuratica for Windows recipe. Also, we'll need to have called the init-mma function.

Also, we need to make sure that the Clojuratica namespace is imported into our script or REPL:

(use 'clojuratica)

Moreover, we need a Mathematica file to run. I created one called line-integral.m, and it contains these lines:

SyntaxInformation[
   lineIntegrate] = {"LocalVariables" -> {"Plot", {3, 3}}, 
   "ArgumentsPattern" -> {_, _, _}};

lineIntegrate[r_?VectorQ, f_Function, {t_, tMin_, tMax_}] := 
 Module[{param, localR}, localR = r /. t -> param...