Integrating Clojure into an existing Java project? -
How can I take a large current Java project and start adding the Closer module? For example, in the code below, I would like to provide the following functions in Java: state?, Zip, state-list, zipcode list ? Two predicates will return a boolean, but the "getters" arrays will return.
(def * states * (list "nj" "ny" "ca")) (def * zipcodes * (list 12345 54343 98765) (defn member [x class] (if (seq class) ( If (= x (first class)) square (repetition x (rest square)))) (defan state? [AState] (not (= (member aState * states *) zero)) Defan zip? [aZip] (no (= (member aZip * zipcodes *) zero)) (defn state list [] * states *) (defan zipcode -List [] * Zipcode *); --------------- (State? "AA") (State? "CA") (Zip 11111) (Zip 12345 )
I use it n I will compile the add java file as a build depository to the jar file here is a very good leiningen using Leiningen then you will say it directly from java Leiningen is a uberjar option that bulds in the clojure and All your clojary dependencies so that you only need to worry about a file I like it because its less work
More Java-friendly approach is one to make it with Java project To add work to T, call to-array
to call some of its work
for those who need to return the proper Java Array; P>
Unlike many of the "Call to Closer", you will not need to call Closure Runtime RT.
PS: My favorite tag line "I would like to use a java library named Closer" I asked Rich that it was good;)
Comments
Post a Comment