RosettaCodeData/Task/Matrix-transposition/Haskell/matrix-transposition-2.hs

8 lines
172 B
Haskell
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
import Data.Array
swap (x,y) = (y,x)
transpArray :: (Ix a, Ix b) => Array (a,b) e -> Array (b,a) e
transpArray a = ixmap (swap l, swap u) swap a where
(l,u) = bounds a