On Mon, 2011-10-10 at 18:16 -0700, Ari wrote: > Unfortunately, the > solution wraps the result within another list, anyone know why? > Thanks. > > (defn collapse [data & keys-coll] > (if (map? data) > (for [[k v] data] > (collapse v (if (nil? keys-coll) > (conj [] k) > (conj (into [] keys-coll) k)))) > (hash-map (flatten keys-coll) data)))
I've reindented your example slightly, which should make it clearer: one of your branches is a `for', which always yields a lazy sequence. Rewriting to the equivalent `map' form would make it even clearer. This does yield an interesting potential alternative, though: you could think of maps and vectors as key/value sequences all the way down, so producing a lazy result. You can always get the map back with (into {} ...) at that point. -- Stephen Compall ^aCollection allSatisfy: [:each|aCondition]: less is better -- 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