Re: Two potential map-util functions

2010-03-11 Thread Luka
Thanks everyone for answers! -- 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 new members are moderated - please be patient with your first post. To unsubscribe from th

Re: Two potential map-util functions

2010-03-09 Thread Michał Marczyk
On 9 March 2010 22:58, Rick Moynihan wrote: > There a parity between this and clojure.contrib.seq-utils/flatten > (which doesn't work with maps)...  So how about this lazy non stack > consuming alternative? > > (defn leaves [m] > (filter >  (complement map?) >  (rest (tree-seq map? #(vals %) >    

Re: Two potential map-util functions

2010-03-09 Thread Rick Moynihan
On 9 March 2010 08:09, Meikel Brandmeyer wrote: > Hi, > > On Mar 8, 2:59 pm, Luka wrote: > >> (defn leafs [m] >>   (loop [vs (vals m), accum []] >>     (if (empty? vs) >>       accum >>       (let [v (first vs)] >>         (if (map? v) >>           (recur (rest vs) (into accum (leafs v))) >>    

Re: Two potential map-util functions

2010-03-09 Thread cageface
On Mar 9, 12:09 am, Meikel Brandmeyer wrote: > How about this? > > (defn leafs >   ... This should be leaves, not leafs, right? Another one of those weird irregular English plurals. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this gro

Re: Two potential map-util functions

2010-03-09 Thread Steve Purcell
On 8 Mar 2010, at 13:59, Luka wrote: > Other thing I would like to ask is how can I see what is different in > 40 github clones of clojure.contrib without clicking on every clone? Either: 1. Use the github network browser: http://github.com/richhickey/clojure-contrib/network (use left/ri

Re: Two potential map-util functions

2010-03-09 Thread David Santiago
Hi, I actually wrote a sort of counterpart to leafs a while back: (defn- rmap   "Implementation core for map-at-levels."   [func obj lvls lvl]   (let [children-mapped (if (coll? obj) (for [c obj] (rmap func c lvls (inc lvl)))

Re: Two potential map-util functions

2010-03-09 Thread Meikel Brandmeyer
Hi, On Mar 8, 2:59 pm, Luka wrote: > (defn leafs [m] >   (loop [vs (vals m), accum []] >     (if (empty? vs) >       accum >       (let [v (first vs)] >         (if (map? v) >           (recur (rest vs) (into accum (leafs v))) >           (recur (rest vs) (conj accum v))) How about this? (

Re: Two potential map-util functions

2010-03-08 Thread Timothy Pratley
>      true (update-in m (butlast v) #(dissoc % (last v)) No need for an unnamed function: true (update-in m (butlast v) dissoc (last v)) Regards, Tim. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clo

Two potential map-util functions

2010-03-08 Thread Luka
I'm aware of clojure-dev group, but being new to clojure, i thought I should start here first. These are two methods I've needed in my project and I didn't found better way to accomplish these tasks. First function returns vector of leaf nodes in a map, and second dissociates in nested map. First q