Hi,

On 13 Apr., 14:25, Baishampayan Ghose <b.gh...@gmail.com> wrote:

> By the way, both of your functions raised ClassCastException.

Both work for me, although in the flatten-maps-lazy there is a typo in
the recursive call. It should be named flatten-maps-lazy there, too.

user=> (defn flatten-maps-lazy
  [coll]
  (lazy-seq
    (when-let [s (seq coll)]
      (let [m (first s)]
        (cons (dissoc m :c) (flatten-maps-lazy (concat (get m :c)
(rest s))))))))
#'user/flatten-maps-lazy
user=> (flatten-maps-lazy data)
({:a 1, :b 1} {:a 1, :b 1} {:a 1, :b 1} {:a 1, :b 1} {:a 1, :b 1} {:a
1, :b 1} {:a 1, :b 1} {:a 1, :b 1})
user=> (defn flatten-maps-eager
  [coll]
  (reduce #(into (conj %1 (dissoc %2 :c)) (flatten-maps-eager (get
%2 :c))) [] coll))
#'user/flatten-maps-eager
user=> (flatten-maps-eager data)
[{:a 1, :b 1} {:a 1, :b 1} {:a 1, :b 1} {:a 1, :b 1} {:a 1, :b 1} {:a
1, :b 1} {:a 1, :b 1} {:a 1, :b 1}]

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