Hi! I'm a beginner at clojure and enjoying the learning process. While writing my first nontrivial program, I noticed that I'm transforming only first elements in the list, so I factored this transformation out by writing next function:
(defn map-first [f coll] (map #(cons (f (first %)) (rest %)) coll)) And it almost works as expected: Clojure> (map-first #(* 2 %) '((2) (3 3) (3 [2 4]) *[4 10]*)) ((4) (6 3) (6 [2 4]) *(8 10)*) Note that the last element of the list is a vector, but ends up as a list. Sure, my program doesn't complain and I don't see a scenario where this might be a problem, but I wondered if there is some way to preserve vectors. Second question that is less academic: how about performance? Would it be much better, where possible, to start mapping these values separately and only then build the whole structure or is there not much to be gained? Thank you very much for attention! -- 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