Browse Source

adding an elisp function for transposing a matrix

Eric Schulte 16 years ago
parent
commit
00ce2a5e25
1 changed files with 18 additions and 0 deletions
  1. 18 0
      library-of-babel.org

+ 18 - 0
library-of-babel.org

@@ -52,6 +52,24 @@ plot(data)
 
 ** Gnuplot
 
+* Table/Matrix manipulation
+
+Elegant lisp code for transposing a matrix.
+
+#+tblname: transpose-example
+| 1 | 2 | 3 |
+| 4 | 5 | 6 |
+
+#+srcname: transpose
+#+begin_src emacs-lisp :var table=transpose-example
+  (apply #'mapcar* #'list table)
+#+end_src
+
+#+resname:
+| 1 | 4 |
+| 2 | 5 |
+| 3 | 6 |
+
 * Misc
 #+srcname: python-identity(a=1)
 #+begin_src python