Skip to content

Instantly share code, notes, and snippets.

@borkdude
Last active August 29, 2015 13:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save borkdude/9016815 to your computer and use it in GitHub Desktop.
Save borkdude/9016815 to your computer and use it in GitHub Desktop.
Clojure invoked from Java, from a simple Maven project with the only dependency being the latest Clojure.
import clojure.java.api.Clojure;
import clojure.lang.IFn;
/**
* Created by Borkdude on 15-02-14.
*/
public class Main {
public static void main(String[] args) {
Object vector = Clojure.read("[1 2 3 4 5]");
IFn reduce = Clojure.var("clojure.core","reduce");
IFn product = Clojure.var("clojure.core","*");
Long result = (Long) reduce.invoke(product,vector);
System.out.println(result); // 120
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment