Re: How to generalize these functions

2013-10-02 Thread Yoshinori Kohyama
Smart! That's just what I want to do. Thanks, Leif and the author of Prismimatic. Best Regards, Yoshinori Kohyama -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from

Re: How to generalize these functions

2013-10-02 Thread Leif
I think functions like this become pretty clear if you pull out 'unfold' and 'fold' utilites, like: https://github.com/Prismatic/plumbing/blob/master/src/plumbing/map.clj#L42 Their 'flatten' generates a seq [path value] pairs, and 'unflatten' turns that back into a map. With these, you can wri

How to generalize these functions

2013-10-01 Thread Yoshinori Kohyama
Hi clojurians. I have functions for nested maps. They obviously have a same structure. Does anyone teach me a way to generalize them with a macro, a function or an existing API? (defn flatten-map [m kf vf] (into {} ((fn g [kv n] (if (map? n) (apply concat (ke