B4J Code Snippet Calling Clojure from B4J

Download Clojure 1.6.0 file from http://clojure.org/downloads

(Specifically http://repo1.maven.org/maven2/org/clojure/clojure/1.6.0/clojure-1.6.0.zip)


Extract clojure-1.6.0.jar from clojure-1.6.0.zip, and put it in the Additional Libraries classpath.

Then

B4X:
'...
'...
#AdditionalJar: clojure-1.6.0
'...
'...

Dim oClojure As JavaObject
Dim oIFn As JavaObject
Dim sResult As String

oClojure.InitializeStatic( "clojure.java.api.Clojure" )
    
oIFn =  oClojure.RunMethodJO( "var", Array As Object( "clojure.core", "+" ) )

sResult =  oIFn.RunMethodJO( "invoke", Array As Object( 1, 2 ) )            '// Returns 3
 
Top