On 10/01/13 12:57, Jonathon McKitrick wrote:
Excellent stuff, guys. Thanks for the help.
I just got 'Joy of Clojure' and 'Clojure Programming' in the mail
yesterday so hopefully I'll be up to speed quickly.
no worries...happy reading! :-)
Jim
--
You received this message because you are su
Excellent stuff, guys. Thanks for the help.
I just got 'Joy of Clojure' and 'Clojure Programming' in the mail yesterday
so hopefully I'll be up to speed quickly.
On Wednesday, January 9, 2013 1:37:45 PM UTC-5, Jim foo.bar wrote:
>
> On 09/01/13 18:20, Jim - FooBar(); wrote:
>
> Alex's soluti
On 09/01/13 18:20, Jim - FooBar(); wrote:
Alex's solution is also quite idiomatic and it takes care of the
transient/peristent conversion as well...It seems slightly heavier
though cos you're building an intermediate vector.
CORRECTION: you'd be building MANY intermediate vectors...as many as
obviously, you would use 'assoc' in your reducing fn...If your old-map
is rather big then you can start with a transient version of a map and
persist it at the end of the entire operation.
new example:
(peristent!
(reduce-kv #(assoc! % (transform %2) %3) (transient (hash-map)) old-map))
;;% is
you can use reduce-kv...This is exactly its purpose - to be able to
reduce maps without the need of destructuring
example:
(reduce-kv some-fn-with-3-args {} old-map)
Jim
On 09/01/13 18:09, Jonathon McKitrick wrote:
I have a map derived from JSON data where the keys are strings. I
want to bu
Something like this?
(into {}
(for [[k v] my-map] :when (pred k v)
[(transform k) v]))
~BG
Sent from phone. Please excuse brevity.
On 9 Jan 2013 23:39, "Jonathon McKitrick" wrote:
> I have a map derived from JSON data where the keys are strings. I want to
> build a new map from this one