On Thu, Feb 3, 2011 at 4:33 PM, Base <basselh...@gmail.com> wrote: > Thats the one! > > Now I just have to understand it... > > The first apply is throwing me a little.
Start with (map foo [1 2 3] [4 5 6] [7 8 9]) That calls foo with the first elements of the collections (so, 1 4 7), then again with the second (2 5 8), and then the third (3 6 9). Now, if foo is vector the return values will be [1 4 7], [2 5 8], and [3 6 9]. Which are the rows of your transposed matrix. (apply map vector matrix) does (map foo row1 row2 row3) in the case of a three-row matrix, for instance, and more generally should extract the columns of any matrix. (vec ...) wrapped around it converts the seq return value into a vector. Note that (vec '(1 2 3)) => [1 2 3]; (vector 1 2 3) => [1 2 3], i.e. (vec foo) = (apply vector foo). -- 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