Database Reference
In-Depth Information
How it works…
There's one important point to note about this recipe.
~(i/sel dataset :cols col)
The code that calls Mathematica can't call back out to evaluate expressions that we pass it,
so we have to do it ourselves irst. If we stick a quasi-quote expander to expressions, then
Clojure makes the i/sel call and interpolates the results into the body of the function.
Evaluating Mathematica scripts from
Clojuratica
Calling single functions is good and very useful, but sometimes we might have a number of
operations in a ile 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 ile 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;
Integrate[(f[localR, #] Sqrt[#.#]) &@D[localR, param],
{param, tMin, tMax}]]
lineIntegrate[{Cos[t], Sin[t]}, 1 &, {t, 0, 2 Pi}]
 
Search WWH ::




Custom Search