Hi,

haha! Golf! I haven't tested the speed, but this should be straight-
forward:

(defn flatten-maps-lazy
  [coll]
  (lazy-seq
    (when-let [s (seq coll)]
      (let [m (first s)]
        (cons (dissoc m :c) (flatten-maps (concat (get m :c) (rest
s))))))))

However your specification was not very clear how the ordering of the
flatten should be. The above reflects the intent as far as I
understood it. Your implementation was also not clear because you mix
conj with vectors and sequences which add at the end resp. front. I
think you meant something like the following.

(defn flatten-maps-eager
  [coll]
  (reduce #(into (conj %1 (dissoc %2 :c)) (flatten-maps-eager (get
%2 :c))) [] coll))

Note: both implementations are prone to stackoverflow.

Sincerely
Meikel

-- 
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 this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to