Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import android.util.Log;
- import clojure.lang.IFn;
- import clojure.lang.RT;
- import clojure.lang.Var;
- import clojure.lang.Compiler;
- import clojure.java.api.Clojure;
- import java.io.StringReader;
- public class ScriptManager {
- private static ScriptManager instance = null;
- public static ScriptManager getInstance() {
- if(instance == null) {
- instance = new ScriptManager();
- }
- return instance;
- }
- public void runTest() {
- // Load the Clojure script -- as a side effect this initializes the runtime.
- String str = "(ns user) (defn foo [a b] (str a \" \" b))";
- //RT.loadResourceScript("foo.clj");
- Compiler.load(new StringReader(str));
- IFn map = Clojure.var("clojure.core", "map");
- IFn inc = Clojure.var("clojure.core", "inc");
- map.invoke(inc, Clojure.read("[1 2 3]"));
- // Get a reference to the foo function.
- IFn foo = Clojure.var("user", "foo");
- // Call it!
- Object result = foo.invoke("Hi", "there");
- //Log.v("ScriptManager", result.toString());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement