On Tue, 2012-09-04 at 14:34 -0700, Mark Hamstra wrote:
> What I am eventually working toward is being able to do the equivalent
> to the above Scala interaction in Clojure:
>
>
> user=> (framework-map #(+ % 1) aDataSet)
>
>
> but as an intermediate step, I'm trying to get named function-like
> parameters working before tackling anonymous functions.
I believe it will actually be easier to get going with functions. You
should be able to write these functions with `reify' or `deftype' on
scala.FunctionN or `proxy' on scala.AbstractFunctionN:
(defn scala-function1
"Convert a one-argument Clojure function to a scala.Function1."
[f]
(reify scala.Function1
(apply [_ x] ...)
...other methods...))
(defn scala-function2
...and so on
The next step is to build a `scala-function' that picks the right
FunctionN interface to implement based on arities of the IFn you get as
input.
> private def getClassReader(cls: Class[_]): ClassReader = {
> logInfo("attempted class name: " + cls.getName.replaceFirst("^.*\
> \.", "") + ".class")
> new ClassReader(cls.getResourceAsStream(
> cls.getName.replaceFirst("^.*\\.", "") + ".class"))
> }
That assumes that this craziness doesn't get in the way. The trick here
is that by putting your reify/deftype/proxy *once*, AOTing that, you'll
reuse the same Scala function class for every Clojure function. That
depends, of course, on the Clojure functions *not* dropping into this
nonsense.
--
Stephen Compall
"^aCollection allSatisfy: [:each | aCondition]": less is better than
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en