(map #(vec (take (inc %) a1)) (range (count a1)))

does it the lovely map.

/Linus

2011/11/9 Shoeb Bhinderwala <shoeb.bhinderw...@gmail.com>

> 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 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

-- 
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