Last active
August 29, 2015 13:56
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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