From 005cb3298c5f86c50a1c05970c5a0fb8e0e95e44 Mon Sep 17 00:00:00 2001 From: Isaac Douglas Date: Sun, 31 Oct 2021 21:40:52 -0300 Subject: [PATCH] add Transpose --- src/Maths/Transpose.hs | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 src/Maths/Transpose.hs diff --git a/src/Maths/Transpose.hs b/src/Maths/Transpose.hs new file mode 100644 index 0000000..a14b8a9 --- /dev/null +++ b/src/Maths/Transpose.hs @@ -0,0 +1,9 @@ +module Maths.Transpose where + +-- Return the transpose of a matrix +transpose :: [[a]] -> [[a]] +transpose ([]:_) = [] +transpose x = (map head x) : transpose (map tail x) + +main = do + print (transpose [[1, 2, 3], [4, 5, 6]]) \ No newline at end of file