public class Clojure extends Object
The Clojure class provides a minimal interface to bootstrap Clojure access from other JVM languages. It provides:
IFn interface.read for reading data using
Clojure's edn readerTo lookup and call a Clojure function:
IFn plus = Clojure.var("clojure.core", "+");
plus.invoke(1, 2);
Functions in clojure.core are automatically loaded. Other
namespaces can be loaded via require:
IFn require = Clojure.var("clojure.core", "require");
require.invoke(Clojure.read("clojure.set"));
IFns can be passed to higher order functions, e.g. the
example below passes inc to map:
IFn map = Clojure.var("clojure.core", "map");
IFn inc = Clojure.var("clojure.core", "inc");
map.invoke(inc, Clojure.read("[1 2 3]"));| Modifier and Type | Method and Description |
|---|---|
static Object |
read(String s)
Read one object from the String s.
|
static IFn |
var(Object qualifiedName)
Returns the var associated with qualifiedName.
|
static IFn |
var(Object ns,
Object name)
Returns an IFn associated with the namespace and name.
|
public static IFn var(Object qualifiedName)
qualifiedName - a String or clojure.lang.Symbolpublic static IFn var(Object ns, Object name)
ns - a String or clojure.lang.Symbolname - a String or clojure.lang.Symbolpublic static Object read(String s)
s - a StringCopyright © 2024. All rights reserved.