Hi,
Am 18.09.2011 um 04:58 schrieb Eamonn:
> I tried the following
> Var keyword = RT.var("clojure.core", "keyword");
> Var hashMap = RT.var("clojure.core", "hash-map");
> hashMap.invoke(keyword.invoke("a"), 1);
>
> then I created the following function
> (defn foo[key paramMap](key paramMap))
>
> Object result=foo.invoke(keyword.invoke("a"), hashMap);
You pass the hash-map function, not a map. Just as in clojure you have to
capture the return value.
Object theMap = hashMap.invoke(keyword.invoke("a"), 1);
Object result = foo.invoke(keyword.invoke("a"), theMap);
You get caught be the keyword lookup, because keywords return nil on
non-map/set objects. If you change your foo as follows, you will get 5.
(defn foo [k m] (k m 5))
> But I got null returned but when I do as you suggest
> Object result=foo.invoke(keyword.invoke("a"),
> hashMap.invoke(keyword.invoke("a"), 1));
> I get 1 returned
Here you pass the return value of the hash-map call directly. Hence it works.
Sincerely
Meikel
--
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