bavardage (owner)

Revisions

gist: 228132 Download_button fork
public
Public Clone URL: git://gist.github.com/228132.git
Embed All Files: show embed
transpose.hs #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import Data.List (intercalate)
 
showMatrix xs = intercalate "\n" $ map show xs
 
 
tranRow row = map (\x -> [x]) row
 
transpose :: [[a]] -> [[a]]
transpose [] = [[]]
transpose (x:[]) = tranRow x
transpose (x:xs) = zipWith (++) (tranRow x) (transpose xs)
 
 
test1 = [[1,2,3],[4,5,6],[7,8,9]]
test2 = [[1,2,3],[4,5,6]]