Re: Getting index of char from end

2011-11-12 Thread Jestan Nirojan
)) Regards. Jestan Nirojan On Nov 12, 12:07 pm, Jestan Nirojan jestanniro...@gmail.com wrote: I think regex free solution is best for this (defn last-indexof [s c]    (- s (filter #(= c %)) count dec) On Nov 12, 3:36 am, jongwon.choi oz.jongwon.c...@gmail.com wrote: Hi I'm wondering

Re: Getting index of char from end

2011-11-11 Thread Jestan Nirojan
I think regex free solution is best for this (defn last-indexof [s c] (- s (filter #(= c %)) count dec) On Nov 12, 3:36 am, jongwon.choi oz.jongwon.c...@gmail.com wrote: Hi I'm wondering the best way to express:      (position #\a abba :from-end t) Should I use interop?      

Recursively convert Java Map to Clojure Map

2011-10-15 Thread Jestan Nirojan
] (walk-coll (partial postwalk-coll f) f form)) (defn as-clj-map [m] (let [f (fn [[k v]] (if (string? k) [(keyword k) v] [k v]))] (postwalk-coll (fn [x] (if (instance? java.util.Map x) (into {} (map f x)) x)) m))) Thanks and regards. -Jestan Nirojan -- You received this message because you

Re: Recursively convert Java Map to Clojure Map

2011-10-15 Thread Jestan Nirojan
Your solution worked, about 4x~5x improvement. Thanks a lot BG. regards. -Jestan Nirojan On Oct 15, 2:10 pm, Baishampayan Ghose b.gh...@gmail.com wrote: I have a Java Map contains Map of Maps/List (JSON like map) and have to convert to Clojure map (This happens at Java - Clojure Interop

Re: Sum on a list of maps

2011-10-14 Thread Jestan Nirojan
I would write like this (defn sum-by-type [coll] (- coll (map (fn [ {v Value t Type } ] {t (read-string v) })) (apply (partial merge-with + If the map is keyword int map, it will be simpler than above (defn sum-by-type [coll] (- coll (map (fn [ {v :value t :type } ] {t v}))

Re: Sum on a list of maps

2011-10-14 Thread Jestan Nirojan
} ] {t v})) (apply (partial merge-with +))) Jestan Nirojan. On Oct 15, 12:46 am, Dave Ray dave...@gmail.com wrote: Someone cleverer than me to post the built-in function that already does exactly what you want, but here's one way: (defn sum-by-type [in]   (- in     (group-by #(get % Type