In clojure a possible representation of a matrix is a vector of vectors, i.e. [[1 2] [3 4]]
.
A possible implementation of transposing a matrix would be:
The usual solution is
(defn transpose [m]
(apply mapv vector m))
As of 2014, I would recommend using core.matrix for any numerical work in Clojure.
Among other things, this provides implementations of all the most common matrix operations:
(use 'clojure.core.matrix)
(transpose [[1 2] [3 4]])
=> [[1 3] [2 4]]