Does Clojure have the equivalent of Haskell's 'scan' function? (I am on my phone...) Seems like a solution with that would be nice. (scan is like reduce except it keeps all intermediate results) On Nov 9, 2011 5:57 PM, "Linus Ericsson" <[email protected]> wrote:
> (map #(vec (take (inc %) a1)) (range (count a1))) > > does it the lovely map. > > /Linus > > 2011/11/9 Shoeb Bhinderwala <[email protected]> > >> Is there a more elegant/idomatic way to achieve the following result: >> >> user=> a1 >> ["a" "b" "c" "d"] >> >> user=> (map-indexed (fn [n x] (vec (take (inc n) x))) (take (count a1) >> (repeat a1))) >> (["a"] ["a" "b"] ["a" "b" "c"] ["a" "b" "c" "d"]) >> >> -- >> You received this message because you are subscribed to the Google >> Groups "Clojure" group. >> To post to this group, send email to [email protected] >> Note that posts from new members are moderated - please be patient with >> your first post. >> To unsubscribe from this group, send email to >> [email protected] >> For more options, visit this group at >> http://groups.google.com/group/clojure?hl=en > > > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to [email protected] > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to [email protected] Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/clojure?hl=en
