Transpose in Data.List is the following:

transpose               :: [[a]] -> [[a]]
transpose []             = []
transpose ([]   : xss)   = transpose xss
transpose ((x:xs) : xss) = (x : [h | (h:_) <- xss]) : transpose (xs :
[ t | (_:t) <- xss])


Yet this seems to work.

transp :: [[b]] -> [[b]]
transp ([]:_)   = []
transp rows     = map head rows : transp (map tail rows)


Why is the the transpose function in Data.List more complicated?

--
--
Regards,
KC

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to