Anonymous user
Matrix transposition: Difference between revisions
m
Improved clojure section with sample output
m (fixed unclosed tag) |
m (Improved clojure section with sample output) |
||
Line 585:
=={{header|Clojure}}==
(apply map list m))▼
<lang lisp>
(
"Switch rows with columns."
(vec (apply map vector m)))</lang>▼
class)
[mtx]
▲(defmethod transpose clojure.lang.PersistentList [m]
(defmethod matrix-transpose clojure.lang.PersistentVector
[mtx]
</lang>
Sample output:
<lang lisp>
=> (matrix-transpose [[1 2 3] [4 5 6]])
[[1 4] [2 5] [3 6]]
</lang>
Line 609 ⟶ 614:
<pre>
> transpose [[1,2,3],[4,5,6]]
[[1,4],[2,5],[3,6]]
</pre>
|