### External Jar Closure

Using jClosure with help of Library JavaObject.
Additional Jar to include: clojure-1.6.0
Reference: http://www.clojure.org
Notes:
• The version of the additional Jar might have changed. Lookup the related website.
Project Attributes
#Region Project Attributes
#MainFormWidth: 600
#MainFormHeight: 400
'External lib
#AdditionalJar: clojure-1.6.0
#End Region
Static Access to the Class Clojure
'Define the JavaObject and init for static access to the class
Dim oClojure As JavaObject
oClojure.InitializeStatic( "clojure.java.api.Clojure" )
Use Clojure's namespaces to locate an arbitrary var, returning the var's IFn interface.
'Some math examples
'Define the var IFn interface and the action
Dim oIFn As JavaObject
oIFn = oClojure.RunMethod( "var", Array As Object( "clojure.core", "+" ) )
'Run the function, idc +
Dim x As Float = oIFn.RunMethod( "invoke", Array As Object( 19, 58 ) )
Log(x)
'The same can be done with other functions, like -, *, /
oIFn = oClojure.RunMethod( "var", Array As Object( "clojure.core", "-" ) )
Dim x As Float = oIFn.RunMethod( "invoke", Array As Object( 19, 58 ) )
Log(x)
oIFn = oClojure.RunMethod( "var", Array As Object( "clojure.core", "*" ) )
Dim x As Float = oIFn.RunMethod( "invoke", Array As Object( 19, 58 ) )
Log(x)
oIFn = oClojure.RunMethod( "var", Array As Object( "clojure.core", "/" ) )
Dim x As Float = oIFn.RunMethod( "invoke", Array As Object( 19, 58 ) )
Log(x)
oIFn = oClojure.RunMethod( "var", Array As Object( "clojure.core", "/" ) )
Try
Dim x As Float = oIFn.RunMethod( "invoke", Array As Object( 19, 0 ) )
Log(x)
Catch
Log(LastException.Message)
End Try
Output:
Program started.
3
77
39
1102
0.32758620381355286
java.lang.ArithmeticException: Divide by zero

Changed: , Category: Jar, File: T6C204M1497.htm, ID: 1497