matrix transposition in clojure

前端 未结 2 1118
野的像风
野的像风 2020-11-27 20:06

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:

2条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-27 20:40

    The usual solution is

    (defn transpose [m]
      (apply mapv vector m))
    

提交回复
热议问题