-
Notifications
You must be signed in to change notification settings - Fork 73
UseInClojure
How to use the toolkit in Clojure
The Java code from this toolkit can easily be used in Clojure -- the project jar has been deployed to maven as me.lizier/jidt for automated inclusion in clojure projects (see further details below).
Here we give only a brief overview of calling Java code from Clojure; several longer examples of using the JIDT toolkit in Clojure can be viewed at Clojure_Examples.
No special installations are required to begin using Java objects in Clojure, these are supported natively as described here.
You can run your Java code in Clojure as follows:
- Add the
["LATEST"](me.lizier/jidt)
for the latest version (or name a specific version) to the:dependencies
vector of yourproject.clj
file (this automatically references the JIDT jar from the leiningen repository and pulls it in). See our sample project.clj file in our Clojure_Examples. - Import the classes you wish to use, e.g.
(import infodynamics.measures.discrete.TransferEntropyCalculatorDiscrete)
. - Create an instance of the calculator you wish to use, e.g.
(def teCalc (TransferEntropyCalculatorDiscrete. 2 1))
- Call methods on the object, e.g.
(.addObservations teCalc sourceArray destArray)
.
Array conversion -- is generally straightforward -- see some details at the Clojure-Java interoperability documentation, and the use of int-array
, into-array
and map
in our Clojure_Examples.
A big thank you to Matthew Chadwick for showing me how to do this and getting things up and running with clojure and leiningen.
JIDT -- Java Information Dynamics Toolkit -- Joseph Lizier et al.
- Home
- Getting started
- ImplementedMeasures
- Demos
- Course (long)
- Tutorial (short)
- Non-Java environments
- FAQs
- Miscellaneous
- For serious developers!
- Publications resulting