Reputation: 51
I need to call a java function from clojure, which takes a float array as a parameter. How would I do this in clojure?
I tried
(classname/function [0.1f 0.2f])
- but this doesn't work. Clearly the issue is with the parameter array. I can call other functions in the class with no problems, provide they don't take an array as a parameter.
Any suggestions?
Thank you
Upvotes: 5
Views: 1226
Reputation: 91554
it looks like that function wants an array of GLfloats so the build in shortcut of float-array
may not give you what you need. the general array builder function is
(into-array type aseq)
so it may look something like:
(def my-array (into-array GLfloat [0.0 0.0 0.0]))
into array is longer winded though more general.
Upvotes: 7
Reputation: 19642
Try float-array
. From the documetation:
user=> (doc float-array)
-------------------------
clojure.core/float-array
([size-or-seq] [size init-val-or-seq])
Creates an array of floats
nil
user=> (float-array [1 2 3])
#<float[] [F@e1666>
user=>
Upvotes: 4