how to filter Java HashMap in Clojure -
i'm trying filter out map entries having values less zero:
(filter #(< 0 (.getvalue %)) map) where map java map (instance of hashmap). i'm getting
actual: java.lang.nullpointerexception: null @ clojure.lang.reflector.invokeinstancemethod (reflector.java:26) what doing wrong?
are sure map instance of hashmap? because works:
=> (import [java.util hashmap]) java.util.hashmap => (def m (hashmap.)) #'.../m => (filter #(< 0 (.getvalue %)) m) () => (.put m 3 4) nil => (.put m 5 -32) nil => (filter #(< 0 (.getvalue %)) m) (#<entry 3=4>) so suppose error somewhere else. maybe if show code creating map? oh, , btw, filtering values greater 0 instead of less zero.
another thing might cause error values inside map not comparable <, should check too.
Comments
Post a Comment